summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES12
-rw-r--r--firmware/export/config.h6
-rw-r--r--firmware/export/config/ihifi760.h187
-rw-r--r--firmware/export/config/ihifi960.h187
-rw-r--r--firmware/target/arm/rk27xx/backlight-rk27xx.c7
-rw-r--r--firmware/target/arm/rk27xx/debug-rk27xx.c3
-rw-r--r--firmware/target/arm/rk27xx/ihifi/button-ihifi.c53
-rw-r--r--firmware/target/arm/rk27xx/ihifi/button-target.h40
-rw-r--r--firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c224
-rw-r--r--firmware/target/arm/rk27xx/ihifi/lcd-target.h26
-rw-r--r--firmware/target/arm/rk27xx/ihifi/power-ihifi.c51
-rw-r--r--firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c65
-rw-r--r--firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c65
-rw-r--r--firmware/target/arm/rk27xx/sd-rk27xx.c3
14 files changed, 928 insertions, 1 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 64041e448e..5591f684af 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -709,6 +709,8 @@ target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
709target/arm/s3c2440/lcd-s3c2440.c 709target/arm/s3c2440/lcd-s3c2440.c
710#elif CONFIG_LCD == LCD_ILI9342 || CONFIG_LCD == LCD_ILI9342C 710#elif CONFIG_LCD == LCD_ILI9342 || CONFIG_LCD == LCD_ILI9342C
711target/arm/rk27xx/ma/lcd-ma.c 711target/arm/rk27xx/ma/lcd-ma.c
712#elif CONFIG_LCD == LCD_IHIFI
713target/arm/rk27xx/ihifi/lcd-ihifi.c
712#endif 714#endif
713 715
714/* USB Stack */ 716/* USB Stack */
@@ -1765,6 +1767,16 @@ target/arm/rk27xx/ma/pca9555-ma.c
1765target/arm/rk27xx/ma/audio-ma.c 1767target/arm/rk27xx/ma/audio-ma.c
1766#endif 1768#endif
1767 1769
1770#if defined(IHIFI760) || defined(IHIFI960)
1771target/arm/rk27xx/ihifi/button-ihifi.c
1772target/arm/rk27xx/ihifi/power-ihifi.c
1773#if defined(IHIFI760)
1774target/arm/rk27xx/ihifi/powermgmt-ihifi760.c
1775#else
1776target/arm/rk27xx/ihifi/powermgmt-ihifi960.c
1777#endif
1778#endif
1779
1768#if (CONFIG_PLATFORM & PLATFORM_ANDROID) 1780#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
1769target/hosted/kernel-unix.c 1781target/hosted/kernel-unix.c
1770target/hosted/filesystem-unix.c 1782target/hosted/filesystem-unix.c
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 23ee56fc75..702a58811c 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -151,6 +151,7 @@
151#define SONY_NWZ_PAD 57 151#define SONY_NWZ_PAD 57
152#define CREATIVE_ZEN_PAD 58 152#define CREATIVE_ZEN_PAD 58
153#define SAMSUNG_YPZ5_PAD 59 153#define SAMSUNG_YPZ5_PAD 59
154#define IHIFI_PAD 60
154 155
155/* CONFIG_REMOTE_KEYPAD */ 156/* CONFIG_REMOTE_KEYPAD */
156#define H100_REMOTE 1 157#define H100_REMOTE 1
@@ -260,6 +261,7 @@
260#define LCD_ILI9342C 57 /* another type of lcd used by HiFi E.T MA9/MA8 */ 261#define LCD_ILI9342C 57 /* another type of lcd used by HiFi E.T MA9/MA8 */
261#define LCD_CREATIVEZENV 58 /* as used by the Creativr Zen V (Plus) */ 262#define LCD_CREATIVEZENV 58 /* as used by the Creativr Zen V (Plus) */
262#define LCD_SAMSUNGYPZ5 59 /* as used by Samsung YP-Z5 */ 263#define LCD_SAMSUNGYPZ5 59 /* as used by Samsung YP-Z5 */
264#define LCD_IHIFI 60 /* as used by IHIFI 760/960 */
263 265
264/* LCD_PIXELFORMAT */ 266/* LCD_PIXELFORMAT */
265#define HORIZONTAL_PACKING 1 267#define HORIZONTAL_PACKING 1
@@ -550,6 +552,10 @@ Lyre prototype 1 */
550#include "config/sonynwze360.h" 552#include "config/sonynwze360.h"
551#elif defined(SAMSUNG_YPZ5) 553#elif defined(SAMSUNG_YPZ5)
552#include "config/samsungypz5.h" 554#include "config/samsungypz5.h"
555#elif defined(IHIFI760)
556#include "config/ihifi760.h"
557#elif defined(IHIFI960)
558#include "config/ihifi960.h"
553#else 559#else
554/* no known platform */ 560/* no known platform */
555#endif 561#endif
diff --git a/firmware/export/config/ihifi760.h b/firmware/export/config/ihifi760.h
new file mode 100644
index 0000000000..ea84a4a891
--- /dev/null
+++ b/firmware/export/config/ihifi760.h
@@ -0,0 +1,187 @@
1/*
2 * This config file is for IHIFI 760
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 92
7
8#define MODEL_NAME "IHIFI 760"
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_DUMMY_CODEC
20#define CODEC_SLAVE
21/* define this if you have a bitmap LCD display */
22#define HAVE_LCD_BITMAP
23
24/* define this if you can flip your LCD */
25/* #define HAVE_LCD_FLIP */
26
27/* define this if you have a colour LCD */
28#define HAVE_LCD_COLOR
29
30/* define this if you want album art for this target */
31#define HAVE_ALBUMART
32
33/* define this to enable bitmap scaling */
34#define HAVE_BMP_SCALING
35
36/* define this to enable JPEG decoding */
37#define HAVE_JPEG
38
39/* define this if you can invert the colours on your LCD */
40/* #define HAVE_LCD_INVERT */
41
42/* define this if you have access to the quickscreen */
43#define HAVE_QUICKSCREEN
44
45/* define this if you would like tagcache to build on this target */
46#define HAVE_TAGCACHE
47
48/* define this if you have a flash memory storage */
49#define HAVE_FLASH_STORAGE
50
51#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
52
53#define CONFIG_NAND NAND_RK27XX
54#define HAVE_SW_TONE_CONTROLS
55
56#define HAVE_SW_VOLUME_CONTROL
57
58/* commented for now */
59/* #define HAVE_HOTSWAP */
60
61#define NUM_DRIVES 1
62#define SECTOR_SIZE 512
63
64/* for small(ish) SD cards */
65#define HAVE_FAT16SUPPORT
66
67/* LCD dimensions */
68#define LCD_WIDTH 320
69#define LCD_HEIGHT 240
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_PAD
87
88/* Define this to enable morse code input */
89#define HAVE_MORSE_INPUT
90
91/* Define this if you do software codec */
92#define CONFIG_CODEC SWCODEC
93
94/* define this if you have a real-time clock */
95/* #define CONFIG_RTC RTC_NANO2G */
96
97/* Define if the device can wake from an RTC alarm */
98/* #define HAVE_RTC_ALARM */
99
100#define CONFIG_LCD LCD_IHIFI
101
102/* Define the type of audio codec */
103/*#define HAVE_RK27XX_CODEC */
104
105/* #define HAVE_PCM_DMA_ADDRESS */
106
107/* Define this for LCD backlight available */
108#define HAVE_BACKLIGHT
109#define HAVE_BACKLIGHT_BRIGHTNESS
110#define MIN_BRIGHTNESS_SETTING 0
111#define MAX_BRIGHTNESS_SETTING 31
112#define DEFAULT_BRIGHTNESS_SETTING 20
113#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
114
115/* Define this if you have a software controlled poweroff */
116#define HAVE_SW_POWEROFF
117
118/* The number of bytes reserved for loadable codecs */
119#define CODEC_SIZE 0x100000
120
121/* The number of bytes reserved for loadable plugins */
122#define PLUGIN_BUFFER_SIZE 0x80000
123
124/* TODO: Figure out real values */
125#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
126#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
127#define BATTERY_CAPACITY_MAX 600 /* 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/* 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/* Virtual LED (icon) */
182#define CONFIG_LED LED_VIRTUAL
183
184#define RKW_FORMAT
185#define BOOTFILE_EXT "rkw"
186#define BOOTFILE "rockbox." BOOTFILE_EXT
187#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config/ihifi960.h b/firmware/export/config/ihifi960.h
new file mode 100644
index 0000000000..3ef6609aa5
--- /dev/null
+++ b/firmware/export/config/ihifi960.h
@@ -0,0 +1,187 @@
1/*
2 * This config file is for IHIFI 960
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 93
7
8#define MODEL_NAME "IHIFI 960"
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_DUMMY_CODEC
20#define CODEC_SLAVE
21/* define this if you have a bitmap LCD display */
22#define HAVE_LCD_BITMAP
23
24/* define this if you can flip your LCD */
25/* #define HAVE_LCD_FLIP */
26
27/* define this if you have a colour LCD */
28#define HAVE_LCD_COLOR
29
30/* define this if you want album art for this target */
31#define HAVE_ALBUMART
32
33/* define this to enable bitmap scaling */
34#define HAVE_BMP_SCALING
35
36/* define this to enable JPEG decoding */
37#define HAVE_JPEG
38
39/* define this if you can invert the colours on your LCD */
40/* #define HAVE_LCD_INVERT */
41
42/* define this if you have access to the quickscreen */
43#define HAVE_QUICKSCREEN
44
45/* define this if you would like tagcache to build on this target */
46#define HAVE_TAGCACHE
47
48/* define this if you have a flash memory storage */
49#define HAVE_FLASH_STORAGE
50
51#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
52
53#define CONFIG_NAND NAND_RK27XX
54#define HAVE_SW_TONE_CONTROLS
55
56#define HAVE_SW_VOLUME_CONTROL
57
58/* commented for now */
59/* #define HAVE_HOTSWAP */
60
61#define NUM_DRIVES 1
62#define SECTOR_SIZE 512
63
64/* for small(ish) SD cards */
65#define HAVE_FAT16SUPPORT
66
67/* LCD dimensions */
68#define LCD_WIDTH 320
69#define LCD_HEIGHT 240
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_PAD
87
88/* Define this to enable morse code input */
89#define HAVE_MORSE_INPUT
90
91/* Define this if you do software codec */
92#define CONFIG_CODEC SWCODEC
93
94/* define this if you have a real-time clock */
95/* #define CONFIG_RTC RTC_NANO2G */
96
97/* Define if the device can wake from an RTC alarm */
98/* #define HAVE_RTC_ALARM */
99
100#define CONFIG_LCD LCD_IHIFI
101
102/* Define the type of audio codec */
103/*#define HAVE_RK27XX_CODEC */
104
105/* #define HAVE_PCM_DMA_ADDRESS */
106
107/* Define this for LCD backlight available */
108#define HAVE_BACKLIGHT
109#define HAVE_BACKLIGHT_BRIGHTNESS
110#define MIN_BRIGHTNESS_SETTING 0
111#define MAX_BRIGHTNESS_SETTING 31
112#define DEFAULT_BRIGHTNESS_SETTING 20
113#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
114
115/* Define this if you have a software controlled poweroff */
116#define HAVE_SW_POWEROFF
117
118/* The number of bytes reserved for loadable codecs */
119#define CODEC_SIZE 0x100000
120
121/* The number of bytes reserved for loadable plugins */
122#define PLUGIN_BUFFER_SIZE 0x80000
123
124/* TODO: Figure out real values */
125#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
126#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
127#define BATTERY_CAPACITY_MAX 600 /* 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/* 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/* Virtual LED (icon) */
182#define CONFIG_LED LED_VIRTUAL
183
184#define RKW_FORMAT
185#define BOOTFILE_EXT "rkw"
186#define BOOTFILE "rockbox." BOOTFILE_EXT
187#define BOOTDIR "/.rockbox"
diff --git a/firmware/target/arm/rk27xx/backlight-rk27xx.c b/firmware/target/arm/rk27xx/backlight-rk27xx.c
index 5d92cd827b..361d18c948 100644
--- a/firmware/target/arm/rk27xx/backlight-rk27xx.c
+++ b/firmware/target/arm/rk27xx/backlight-rk27xx.c
@@ -68,6 +68,13 @@ static const unsigned short lin_brightness[] = {
68 198, 227, 260, 295, 334, 376, 421, 470, 68 198, 227, 260, 295, 334, 376, 421, 470,
69 522, 578, 638, 702, 770, 842, 918, 1000 69 522, 578, 638, 702, 770, 842, 918, 1000
70}; 70};
71#elif defined(IHIFI760) || defined(IHIFI960)
72static const unsigned short lin_brightness[] = {
73 700, 701, 702, 703, 704, 706, 708, 711,
74 714, 717, 721, 726, 731, 737, 743, 751,
75 759, 768, 778, 788, 800, 812, 826, 841,
76 856, 873, 891, 910, 931, 952, 975, 1000
77};
71#endif 78#endif
72 79
73bool _backlight_init(void) 80bool _backlight_init(void)
diff --git a/firmware/target/arm/rk27xx/debug-rk27xx.c b/firmware/target/arm/rk27xx/debug-rk27xx.c
index 79c779461b..83bc1a5af6 100644
--- a/firmware/target/arm/rk27xx/debug-rk27xx.c
+++ b/firmware/target/arm/rk27xx/debug-rk27xx.c
@@ -32,7 +32,8 @@
32 32
33#ifdef RK27_GENERIC 33#ifdef RK27_GENERIC
34#define DEBUG_CANCEL BUTTON_VOL 34#define DEBUG_CANCEL BUTTON_VOL
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#define DEBUG_CANCEL BUTTON_LEFT 37#define DEBUG_CANCEL BUTTON_LEFT
37#endif 38#endif
38 39
diff --git a/firmware/target/arm/rk27xx/ihifi/button-ihifi.c b/firmware/target/arm/rk27xx/ihifi/button-ihifi.c
new file mode 100644
index 0000000000..6477400255
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi/button-ihifi.c
@@ -0,0 +1,53 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 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#include "backlight.h"
27
28void button_init_device(void) {
29 /* setup button gpio as input */
30 GPIO_PCCON &= ~(POWEROFF_BUTTON);
31}
32
33int button_read_device(void) {
34 int adc_val = adc_read(ADC_BUTTONS);
35 int gpio_btn = GPIO_PCDR & BUTTON_PLAY;
36
37 if (adc_val < 270) {
38 if (adc_val < 110) { /* 0 - 109 */
39 return BUTTON_RETURN | gpio_btn;
40 } else { /* 110 - 269 */
41 return BUTTON_MENU |gpio_btn;
42 }
43 } else {
44 if (adc_val < 420) { /* 270 - 419 */
45 return BUTTON_BWD | gpio_btn;
46 } else if (adc_val < 580) { /* 420 - 579 */
47 return BUTTON_FWD | gpio_btn;
48 }
49 }
50 return gpio_btn;
51}
52
53
diff --git a/firmware/target/arm/rk27xx/ihifi/button-target.h b/firmware/target/arm/rk27xx/ihifi/button-target.h
new file mode 100644
index 0000000000..f78727b0f5
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi/button-target.h
@@ -0,0 +1,40 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 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#define BUTTON_FWD 0x00000001
25#define BUTTON_PLAY 0x00000002
26#define BUTTON_BWD 0x00000004
27#define BUTTON_RETURN 0x00000008
28#define BUTTON_MENU 0x00000010
29
30#define BUTTON_LEFT BUTTON_RETURN
31#define BUTTON_RIGHT BUTTON_MENU
32
33#define BUTTON_MAIN (BUTTON_FWD|BUTTON_PLAY| \
34 BUTTON_BWD|BUTTON_RETURN| \
35 BUTTON_MENU)
36
37#define POWEROFF_BUTTON BUTTON_PLAY
38#define POWEROFF_COUNT 30
39
40#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c b/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c
new file mode 100644
index 0000000000..d5906b9dd5
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c
@@ -0,0 +1,224 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 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
30static bool display_on = false;
31
32void lcd_display_init(void)
33{
34 unsigned int x, y;
35
36 lcd_cmd(0xEF);
37 lcd_data(0x03);
38 lcd_data(0x80);
39 lcd_data(0x02);
40
41 lcd_cmd(0x00CF);
42 lcd_data(0x00);
43 lcd_data(0xC1);
44 lcd_data(0x30);
45
46 lcd_cmd(0xED);
47 lcd_data(0x67);
48 lcd_data(0x03);
49 lcd_data(0x12);
50 lcd_data(0x81);
51
52 lcd_cmd(0xE8);
53 lcd_data(0x85);
54 lcd_data(0x11);
55 lcd_data(0x79);
56
57 lcd_cmd(0xCB);
58 lcd_data(0x39);
59 lcd_data(0x2C);
60 lcd_data(0x00);
61 lcd_data(0x34);
62 lcd_data(0x06);
63
64 lcd_cmd(0xF7);
65 lcd_data(0x20);
66
67 lcd_cmd(0xEA);
68 lcd_data(0x00);
69 lcd_data(0x00);
70
71 lcd_cmd(0xC0);
72 lcd_data(0x1D);
73
74 lcd_cmd(0xC1);
75 lcd_data(0x12);
76
77 lcd_cmd(0xC5);
78 lcd_data(0x44);
79 lcd_data(0x3C);
80
81 lcd_cmd(0xC7);
82 lcd_data(0x88);
83
84 lcd_cmd(0x3A);
85 lcd_data(0x55);
86
87 lcd_cmd(0x36);
88 lcd_data(0xA8);
89
90 lcd_cmd(0xB1);
91 lcd_data(0x00);
92 lcd_data(0x17);
93
94 lcd_cmd(0xB6);
95 lcd_data(0x0A);
96 lcd_data(0xA2);
97
98 lcd_cmd(0xF2);
99 lcd_data(0x00);
100
101 lcd_cmd(0x26);
102 lcd_data(0x01);
103
104 lcd_cmd(0xE0);
105 lcd_data(0x0F);
106 lcd_data(0x22);
107 lcd_data(0x1C);
108 lcd_data(0x1B);
109 lcd_data(0x08);
110 lcd_data(0x0F);
111 lcd_data(0x48);
112 lcd_data(0xB8);
113 lcd_data(0x34);
114 lcd_data(0x05);
115 lcd_data(0x0C);
116 lcd_data(0x09);
117 lcd_data(0x0F);
118 lcd_data(0x07);
119 lcd_data(0x00);
120
121 lcd_cmd(0xE1);
122 lcd_data(0x00);
123 lcd_data(0x23);
124 lcd_data(0x24);
125 lcd_data(0x07);
126 lcd_data(0x10);
127 lcd_data(0x07);
128 lcd_data(0x38);
129 lcd_data(0x47);
130 lcd_data(0x4B);
131 lcd_data(0x0A);
132 lcd_data(0x13);
133 lcd_data(0x06);
134 lcd_data(0x30);
135 lcd_data(0x38);
136 lcd_data(0x0F);
137
138 lcd_cmd(0x2A);
139 lcd_data(0x00);
140 lcd_data(0x00);
141 lcd_data(0x01);
142 lcd_data(0x3F);
143
144 lcd_cmd(0x2B);
145 lcd_data(0x00);
146 lcd_data(0x00);
147 lcd_data(0x00);
148 lcd_data(0xEF);
149
150 lcd_cmd(0x11);
151
152 udelay(120000);
153
154 lcd_cmd(0x29);
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 udelay(120000);
175 lcd_cmd(0x29);
176 lcd_cmd(0x2C);
177 } else {
178 lcd_cmd(0x28);
179 }
180
181 display_on = on;
182 LCDC_CTRL &= ~RGB24B;
183}
184
185void lcd_set_gram_area(int x_start, int y_start,
186 int x_end, int y_end)
187{
188 lcdctrl_bypass(1);
189 LCDC_CTRL |= RGB24B;
190 lcd_cmd(0x002A);
191 lcd_data((x_start&0xff00)>>8);
192 lcd_data(x_start&0x00ff);
193 lcd_data((x_end&0xff00)>>8);
194 lcd_data(x_end&0x00ff);
195 lcd_cmd(0x002B);
196 lcd_data((y_start&0xff00)>>8);
197 lcd_data(y_start&0x00ff);
198 lcd_data((y_end&0xff00)>>8);
199 lcd_data(y_end&0x00ff);
200
201 lcd_cmd(0x2C);
202 LCDC_CTRL &= ~RGB24B;
203
204}
205
206bool lcd_active()
207{
208 return display_on;
209}
210
211/* Blit a YUV bitmap directly to the LCD */
212void lcd_blit_yuv(unsigned char * const src[3],
213 int src_x, int src_y, int stride,
214 int x, int y, int width, int height)
215{
216 (void)src;
217 (void)src_x;
218 (void)src_y;
219 (void)stride;
220 (void)x;
221 (void)y;
222 (void)width;
223 (void)height;
224}
diff --git a/firmware/target/arm/rk27xx/ihifi/lcd-target.h b/firmware/target/arm/rk27xx/ihifi/lcd-target.h
new file mode 100644
index 0000000000..0d245c888b
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi/lcd-target.h
@@ -0,0 +1,26 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 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#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/ihifi/power-ihifi.c b/firmware/target/arm/rk27xx/ihifi/power-ihifi.c
new file mode 100644
index 0000000000..780d476112
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi/power-ihifi.c
@@ -0,0 +1,51 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2013 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#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 GPIO_PCCON &= ~(1<<0);
32 while(1);
33}
34
35void power_init(void)
36{
37 GPIO_PCDR |= (1<<0);
38 GPIO_PCCON |= (1<<0);
39}
40
41unsigned int power_input_status(void)
42{
43 unsigned int status = POWER_INPUT_NONE;
44 /* TODO: implement */
45 return status;
46}
47
48bool charging_state(void)
49{
50 return true;
51}
diff --git a/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c
new file mode 100644
index 0000000000..c849bc27e6
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2013 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 "adc.h"
24#include "adc-target.h"
25#include "powermgmt.h"
26
27/* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-60x.
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 /* TODO: this is just an initial guess */
38 3350,
39};
40
41const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
42{
43 3300,
44};
45
46/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
47const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
48{
49 /* FIXME: Uncalibrated curve */
50 { 3300, 3350, 3433, 3516, 3600, 3683, 3767, 3850, 3933, 4017, 4100 }
51};
52
53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
54const unsigned short percent_to_volt_charge[11] =
55 /* TODO: simple copy of discharge curve */
56 { 3300, 3350, 3433, 3516, 3600, 3683, 3767, 3850, 3933, 4017, 4100 };
57
58/* full-scale ADC readout (2^10) in millivolt */
59#define BATTERY_SCALE_FACTOR 6100
60
61/* Returns battery voltage from ADC [millivolts] */
62int _battery_voltage(void)
63{
64 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
65}
diff --git a/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c
new file mode 100644
index 0000000000..c8797c0a32
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2013 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 "adc.h"
24#include "adc-target.h"
25#include "powermgmt.h"
26
27/* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-60x.
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 /* TODO: this is just an initial guess */
38 7050,
39};
40
41const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
42{
43 7000,
44};
45
46/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
47const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
48{
49 /* FIXME: Uncalibrated curve */
50 { 7000, 7050, 7100, 7150, 7200, 7250, 7300, 7350, 7400, 7450, 7500 }
51};
52
53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
54const unsigned short percent_to_volt_charge[11] =
55 /* TODO: simple copy of discharge curve */
56 { 7000, 7050, 7100, 7150, 7200, 7250, 7300, 7350, 7400, 7450, 7500 };
57
58/* full-scale ADC readout (2^10) in millivolt */
59#define BATTERY_SCALE_FACTOR 13000
60
61/* Returns battery voltage from ADC [millivolts] */
62int _battery_voltage(void)
63{
64 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
65}
diff --git a/firmware/target/arm/rk27xx/sd-rk27xx.c b/firmware/target/arm/rk27xx/sd-rk27xx.c
index 9f6ba467b7..deca8a1fa7 100644
--- a/firmware/target/arm/rk27xx/sd-rk27xx.c
+++ b/firmware/target/arm/rk27xx/sd-rk27xx.c
@@ -134,6 +134,9 @@ static inline bool card_detect_target(void)
134 return !(GPIO_PFDR & (1<<2)); 134 return !(GPIO_PFDR & (1<<2));
135#elif defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) 135#elif defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C)
136 return (GPIO_PCDR & 0x80); 136 return (GPIO_PCDR & 0x80);
137#elif defined(IHIFI760) || defined(IHIFI960)
138 /* TODO: find out pin */
139 return true;
137#else 140#else
138#error "Unknown target" 141#error "Unknown target"
139#endif 142#endif