diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 14 | ||||
-rw-r--r-- | firmware/export/config.h | 2 | ||||
-rw-r--r-- | firmware/export/config/sansafuzev2.h | 211 | ||||
-rw-r--r-- | firmware/target/arm/as3525/button-e200v2-fuze.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/as3525/dbop-as3525.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h | 32 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/button-target.h | 63 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c | 447 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/powermgmt-fuzev2.c | 52 | ||||
-rw-r--r-- | firmware/target/arm/as3525/system-as3525.c | 2 |
10 files changed, 824 insertions, 3 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 894ee07c38..04fdae0f9f 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -1296,6 +1296,20 @@ target/arm/as3525/sansa-fuze/powermgmt-fuze.c | |||
1296 | #endif /* !SIMULATOR */ | 1296 | #endif /* !SIMULATOR */ |
1297 | #endif /* SANSA_FUZE */ | 1297 | #endif /* SANSA_FUZE */ |
1298 | 1298 | ||
1299 | #ifdef SANSA_FUZEV2 | ||
1300 | #ifndef SIMULATOR | ||
1301 | target/arm/as3525/button-e200v2-fuze.c | ||
1302 | target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c | ||
1303 | target/arm/as3525/lcd-as-e200v2-fuze.S | ||
1304 | target/arm/as3525/backlight-e200v2-fuze.c | ||
1305 | target/arm/as3525/dbop-as3525.c | ||
1306 | #ifndef BOOTLOADER | ||
1307 | target/arm/powermgmt-ascodec.c | ||
1308 | target/arm/as3525/sansa-fuzev2/powermgmt-fuzev2.c | ||
1309 | #endif /* !BOOTLOADER */ | ||
1310 | #endif /* !SIMULATOR */ | ||
1311 | #endif /* SANSA_FUZEV2 */ | ||
1312 | |||
1299 | #ifdef IAUDIO_7 | 1313 | #ifdef IAUDIO_7 |
1300 | #ifndef SIMULATOR | 1314 | #ifndef SIMULATOR |
1301 | drivers/nand_id.c | 1315 | drivers/nand_id.c |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 3c70bb6880..c7ddbfc3ef 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -392,6 +392,8 @@ Lyre prototype 1 */ | |||
392 | #include "config/sansam200v4.h" | 392 | #include "config/sansam200v4.h" |
393 | #elif defined(SANSA_FUZE) | 393 | #elif defined(SANSA_FUZE) |
394 | #include "config/sansafuze.h" | 394 | #include "config/sansafuze.h" |
395 | #elif defined(SANSA_FUZEV2) | ||
396 | #include "config/sansafuzev2.h" | ||
395 | #elif defined(SANSA_C200V2) | 397 | #elif defined(SANSA_C200V2) |
396 | #include "config/sansac200v2.h" | 398 | #include "config/sansac200v2.h" |
397 | #elif defined(SANSA_VIEW) | 399 | #elif defined(SANSA_VIEW) |
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h new file mode 100644 index 0000000000..b806354b09 --- /dev/null +++ b/firmware/export/config/sansafuzev2.h | |||
@@ -0,0 +1,211 @@ | |||
1 | /* | ||
2 | * This config file is for the Sandisk Sansa Fuze | ||
3 | */ | ||
4 | #define TARGET_TREE /* this target is using the target tree system */ | ||
5 | |||
6 | /* For Rolo and boot loader */ | ||
7 | #define MODEL_NUMBER 68 | ||
8 | #define MODEL_NAME "Sandisk Sansa Fuze v2" | ||
9 | |||
10 | #define HW_SAMPR_CAPS SAMPR_CAP_ALL | ||
11 | |||
12 | /* define this if you have recording possibility */ | ||
13 | //#define HAVE_RECORDING | ||
14 | |||
15 | //#define REC_SAMPR_CAPS SAMPR_CAP_ALL | ||
16 | |||
17 | /* Default recording levels */ | ||
18 | #define DEFAULT_REC_MIC_GAIN 23 | ||
19 | #define DEFAULT_REC_LEFT_GAIN 23 | ||
20 | #define DEFAULT_REC_RIGHT_GAIN 23 | ||
21 | |||
22 | /* Define bitmask of input sources - recordable bitmask can be defined | ||
23 | explicitly if different */ | ||
24 | #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) | ||
25 | |||
26 | /* define this if you have a bitmap LCD display */ | ||
27 | #define HAVE_LCD_BITMAP | ||
28 | /* define this if you have a colour LCD */ | ||
29 | #define HAVE_LCD_COLOR | ||
30 | |||
31 | #ifndef BOOTLOADER/* 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 have a light associated with the buttons */ | ||
41 | #define HAVE_BUTTON_LIGHT | ||
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 LCD enable function */ | ||
53 | //#define HAVE_LCD_ENABLE | ||
54 | |||
55 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE | ||
56 | should be defined as well. | ||
57 | #define HAVE_LCD_SLEEP | ||
58 | #define HAVE_LCD_SLEEP_SETTING | ||
59 | */ | ||
60 | |||
61 | /* define this if you can flip your LCD */ | ||
62 | //#define HAVE_LCD_FLIP | ||
63 | |||
64 | /* define this if you can invert the colours on your LCD */ | ||
65 | //#define HAVE_LCD_INVERT | ||
66 | |||
67 | |||
68 | /* define this if you have a real-time clock */ | ||
69 | #define CONFIG_RTC RTC_AS3514 | ||
70 | |||
71 | /* There is no hardware tone control */ | ||
72 | #define HAVE_SW_TONE_CONTROLS | ||
73 | |||
74 | #endif /* !BOOTLOADER */ | ||
75 | |||
76 | /* put the lcd frame buffer in IRAM */ | ||
77 | #define IRAM_LCDFRAMEBUFFER //IBSS_ATTR | ||
78 | |||
79 | #define CONFIG_KEYPAD SANSA_FUZE_PAD | ||
80 | |||
81 | /* Define this to enable morse code input */ | ||
82 | #define HAVE_MORSE_INPUT | ||
83 | |||
84 | /* Define this if you do software codec */ | ||
85 | #define CONFIG_CODEC SWCODEC | ||
86 | |||
87 | |||
88 | /* LCD dimensions */ | ||
89 | #define LCD_WIDTH 220 | ||
90 | #define LCD_HEIGHT 176 | ||
91 | #define LCD_DEPTH 16 /* 65536 colours */ | ||
92 | #define LCD_PIXELFORMAT RGB565 /* rgb565 */ | ||
93 | |||
94 | |||
95 | /* We're working on the assumption that the AS3525 has something | ||
96 | similar to the AS3514 for audio codec etc */ | ||
97 | #define HAVE_AS3514 | ||
98 | |||
99 | /* Define this if you have a software controlled poweroff */ | ||
100 | #define HAVE_SW_POWEROFF | ||
101 | |||
102 | /* Some Sansa Fuzes seem to be FAT16 formatted */ | ||
103 | #define HAVE_FAT16SUPPORT | ||
104 | |||
105 | /* The number of bytes reserved for loadable codecs */ | ||
106 | #define CODEC_SIZE 0x100000 | ||
107 | |||
108 | /* The number of bytes reserved for loadable plugins */ | ||
109 | #define PLUGIN_BUFFER_SIZE 0x80000 | ||
110 | |||
111 | #define AB_REPEAT_ENABLE 1 | ||
112 | |||
113 | /* FM Tuner - suspected to be the SI4702 */ | ||
114 | #define CONFIG_TUNER SI4700 | ||
115 | /* #define HAVE_TUNER_PWR_CTRL */ | ||
116 | |||
117 | /* Define this for LCD backlight available */ | ||
118 | #define HAVE_BACKLIGHT | ||
119 | #define HAVE_BACKLIGHT_BRIGHTNESS | ||
120 | |||
121 | /* Main LCD backlight brightness range and defaults */ | ||
122 | #define MIN_BRIGHTNESS_SETTING 1 | ||
123 | #define MAX_BRIGHTNESS_SETTING 12 | ||
124 | #define DEFAULT_BRIGHTNESS_SETTING 6 | ||
125 | |||
126 | /* Which backlight fading type? */ | ||
127 | #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING | ||
128 | |||
129 | /* define this if the unit uses a scrollwheel for navigation */ | ||
130 | #define HAVE_SCROLLWHEEL | ||
131 | /* define to activate advanced wheel acceleration code */ | ||
132 | #define HAVE_WHEEL_ACCELERATION | ||
133 | /* define from which rotation speed [degree/sec] on the acceleration starts */ | ||
134 | #define WHEEL_ACCEL_START 540 | ||
135 | /* define type of acceleration (1 = ^2, 2 = ^3, 3 = ^4) */ | ||
136 | #define WHEEL_ACCELERATION 1 | ||
137 | |||
138 | /* define this if you have a flash memory storage */ | ||
139 | #define HAVE_FLASH_STORAGE | ||
140 | |||
141 | /* define this if the flash memory uses the SecureDigital Memory Card protocol */ | ||
142 | #define CONFIG_STORAGE STORAGE_SD | ||
143 | |||
144 | #define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */ | ||
145 | #define BATTERY_CAPACITY_MIN 550 /* min. capacity selectable */ | ||
146 | #define BATTERY_CAPACITY_MAX 550 /* max. capacity selectable */ | ||
147 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | ||
148 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | ||
149 | |||
150 | /* Charging implemented in a target-specific algorithm */ | ||
151 | #define CONFIG_CHARGING 0 | ||
152 | |||
153 | /* define this if the unit can be powered or charged via USB */ | ||
154 | #define HAVE_USB_POWER | ||
155 | |||
156 | /* Define this if you have an AMS AS3525*/ | ||
157 | #define CONFIG_CPU AS3525 | ||
158 | |||
159 | /* Define how much SD sectors are reserved for OF */ | ||
160 | #define AMS_OF_SIZE 0xF000 | ||
161 | |||
162 | /* Define this if you want to use the AS2525 i2c interface */ | ||
163 | #define CONFIG_I2C I2C_AS3525 | ||
164 | |||
165 | /* define current usage levels (based on battery bench) */ | ||
166 | #define CURRENT_NORMAL 65 | ||
167 | #define CURRENT_BACKLIGHT 30 | ||
168 | #define CURRENT_RECORD CURRENT_NORMAL | ||
169 | |||
170 | /* Define this to the CPU frequency */ | ||
171 | #define CPU_FREQ 250000000 | ||
172 | |||
173 | /* Type of LCD */ | ||
174 | #define CONFIG_LCD LCD_FUZE | ||
175 | |||
176 | /* Offset ( in the firmware file's header ) to the file CRC and data. These are | ||
177 | only used when loading the old format rockbox.e200 file */ | ||
178 | #define FIRMWARE_OFFSET_FILE_CRC 0x0 | ||
179 | #define FIRMWARE_OFFSET_FILE_DATA 0x8 | ||
180 | |||
181 | #ifndef BOOTLOADER | ||
182 | #define HAVE_MULTIDRIVE | ||
183 | #define NUM_DRIVES 2 | ||
184 | #define HAVE_HOTSWAP | ||
185 | #endif | ||
186 | |||
187 | #ifndef BOOTLOADER | ||
188 | |||
189 | #define USB_HANDLED_BY_OF | ||
190 | |||
191 | /* USB On-the-go */ | ||
192 | #define CONFIG_USBOTG USBOTG_AS3525 | ||
193 | |||
194 | /* enable these for the experimental usb stack */ | ||
195 | #define HAVE_USBSTACK | ||
196 | #define USB_VENDOR_ID 0x0781 | ||
197 | #define USB_PRODUCT_ID 0x7423 | ||
198 | |||
199 | #endif /* !BOOTLOADER */ | ||
200 | |||
201 | /* Define this if you have adjustable CPU frequency */ | ||
202 | #define HAVE_ADJUSTABLE_CPU_FREQ | ||
203 | |||
204 | #define BOOTFILE_EXT "sansa" | ||
205 | #define BOOTFILE "rockbox." BOOTFILE_EXT | ||
206 | #define BOOTDIR "/.rockbox" | ||
207 | |||
208 | #define ICODE_ATTR_TREMOR_NOT_MDCT | ||
209 | |||
210 | #define INCLUDE_TIMEOUT_API | ||
211 | |||
diff --git a/firmware/target/arm/as3525/button-e200v2-fuze.c b/firmware/target/arm/as3525/button-e200v2-fuze.c index 98c660dd45..2a75fa1e6f 100644 --- a/firmware/target/arm/as3525/button-e200v2-fuze.c +++ b/firmware/target/arm/as3525/button-e200v2-fuze.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "dbop-as3525.h" | 28 | #include "dbop-as3525.h" |
29 | 29 | ||
30 | 30 | ||
31 | #ifdef SANSA_FUZE | 31 | #if defined(SANSA_FUZE) || defined(SANSA_FUZEV2) |
32 | #define DBOP_BIT15_BUTTON BUTTON_HOME | 32 | #define DBOP_BIT15_BUTTON BUTTON_HOME |
33 | #define WHEEL_REPEAT_INTERVAL (HZ/5) | 33 | #define WHEEL_REPEAT_INTERVAL (HZ/5) |
34 | #define WHEEL_COUNTER_DIV 4 | 34 | #define WHEEL_COUNTER_DIV 4 |
diff --git a/firmware/target/arm/as3525/dbop-as3525.c b/firmware/target/arm/as3525/dbop-as3525.c index b54ad17a6c..1730290d46 100644 --- a/firmware/target/arm/as3525/dbop-as3525.c +++ b/firmware/target/arm/as3525/dbop-as3525.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "as3525.h" | 24 | #include "as3525.h" |
25 | #include "dbop-as3525.h" | 25 | #include "dbop-as3525.h" |
26 | 26 | ||
27 | #if defined(SANSA_FUZE) | 27 | #if defined(SANSA_FUZE) || defined(SANSA_FUZEV2) |
28 | #define DBOP_PRECHARGE 0x80FF | 28 | #define DBOP_PRECHARGE 0x80FF |
29 | #elif defined(SANSA_E200V2) || defined(SANSA_C200V2) | 29 | #elif defined(SANSA_E200V2) || defined(SANSA_C200V2) |
30 | #define DBOP_PRECHARGE 0xF0FF | 30 | #define DBOP_PRECHARGE 0xF0FF |
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h b/firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h new file mode 100644 index 0000000000..2d60ac35c2 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 Barry Wardell | ||
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 BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #define _backlight_init() true | ||
25 | void _backlight_on(void); | ||
26 | void _backlight_off(void); | ||
27 | void _backlight_set_brightness(int brightness); | ||
28 | #ifdef HAVE_BUTTON_LIGHT | ||
29 | void _buttonlight_on(void); | ||
30 | void _buttonlight_off(void); | ||
31 | #endif | ||
32 | #endif | ||
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h new file mode 100644 index 0000000000..6dcd37460a --- /dev/null +++ b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
24 | |||
25 | #include <stdbool.h> | ||
26 | #include "config.h" | ||
27 | |||
28 | #define HAS_BUTTON_HOLD | ||
29 | |||
30 | void button_init_device(void); | ||
31 | bool button_hold(void); | ||
32 | int button_read_device(void); | ||
33 | unsigned short button_read_dbop(void); | ||
34 | /* Sandisk Sansa Fuze button codes */ | ||
35 | |||
36 | /* Main unit's buttons */ | ||
37 | #define BUTTON_HOME 0x00000001 | ||
38 | |||
39 | #define BUTTON_DOWN 0x00000002 | ||
40 | #define BUTTON_RIGHT 0x00000004 | ||
41 | |||
42 | #define BUTTON_LEFT 0x00000008 | ||
43 | #define BUTTON_SELECT 0x00000010 | ||
44 | #define BUTTON_UP 0x00000020 | ||
45 | #define BUTTON_POWER 0x00000040 | ||
46 | |||
47 | #define BUTTON_SCROLL_BACK 0x00000080 | ||
48 | #define BUTTON_SCROLL_FWD 0x00000100 | ||
49 | |||
50 | #define BUTTON_HOLD 0x00000400 | ||
51 | |||
52 | #define BUTTON_MAIN (BUTTON_HOME|BUTTON_DOWN|BUTTON_RIGHT|BUTTON_LEFT \ | ||
53 | |BUTTON_SELECT|BUTTON_UP|BUTTON_POWER \ | ||
54 | |BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD \ | ||
55 | |BUTTON_HOLD) | ||
56 | |||
57 | /* No Remote control */ | ||
58 | #define BUTTON_REMOTE 0 | ||
59 | |||
60 | #define POWEROFF_BUTTON BUTTON_POWER | ||
61 | #define POWEROFF_COUNT 10 | ||
62 | |||
63 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c new file mode 100644 index 0000000000..bdf1c704e0 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c | |||
@@ -0,0 +1,447 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Dave Chapman | ||
11 | * | ||
12 | * LCD driver for the Sansa Fuze - controller unknown | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | #include "config.h" | ||
24 | |||
25 | #include "cpu.h" | ||
26 | #include "lcd.h" | ||
27 | #include "file.h" | ||
28 | #include "debug.h" | ||
29 | #include "system.h" | ||
30 | #include "clock-target.h" | ||
31 | #include "dbop-as3525.h" | ||
32 | |||
33 | /* The controller is unknown, but some registers appear to be the same as the | ||
34 | HD66789R */ | ||
35 | static bool display_on = false; /* is the display turned on? */ | ||
36 | |||
37 | /* register defines */ | ||
38 | #define R_START_OSC 0x00 | ||
39 | #define R_DRV_OUTPUT_CONTROL 0x01 | ||
40 | #define R_DRV_WAVEFORM_CONTROL 0x02 | ||
41 | #define R_ENTRY_MODE 0x03 | ||
42 | #define R_COMPARE_REG1 0x04 | ||
43 | #define R_COMPARE_REG2 0x05 | ||
44 | |||
45 | #define R_DISP_CONTROL1 0x07 | ||
46 | #define R_DISP_CONTROL2 0x08 | ||
47 | #define R_DISP_CONTROL3 0x09 | ||
48 | |||
49 | #define R_FRAME_CYCLE_CONTROL 0x0b | ||
50 | #define R_EXT_DISP_IF_CONTROL 0x0c | ||
51 | |||
52 | #define R_POWER_CONTROL1 0x10 | ||
53 | #define R_POWER_CONTROL2 0x11 | ||
54 | #define R_POWER_CONTROL3 0x12 | ||
55 | #define R_POWER_CONTROL4 0x13 | ||
56 | |||
57 | #define R_RAM_ADDR_SET 0x21 | ||
58 | #define R_WRITE_DATA_2_GRAM 0x22 | ||
59 | |||
60 | #define R_GAMMA_FINE_ADJ_POS1 0x30 | ||
61 | #define R_GAMMA_FINE_ADJ_POS2 0x31 | ||
62 | #define R_GAMMA_FINE_ADJ_POS3 0x32 | ||
63 | #define R_GAMMA_GRAD_ADJ_POS 0x33 | ||
64 | |||
65 | #define R_GAMMA_FINE_ADJ_NEG1 0x34 | ||
66 | #define R_GAMMA_FINE_ADJ_NEG2 0x35 | ||
67 | #define R_GAMMA_FINE_ADJ_NEG3 0x36 | ||
68 | #define R_GAMMA_GRAD_ADJ_NEG 0x37 | ||
69 | |||
70 | #define R_GAMMA_AMP_ADJ_RES_POS 0x38 | ||
71 | #define R_GAMMA_AMP_AVG_ADJ_RES_NEG 0x39 | ||
72 | |||
73 | #define R_GATE_SCAN_POS 0x40 | ||
74 | #define R_VERT_SCROLL_CONTROL 0x41 | ||
75 | #define R_1ST_SCR_DRV_POS 0x42 | ||
76 | #define R_2ND_SCR_DRV_POS 0x43 | ||
77 | #define R_HORIZ_RAM_ADDR_POS 0x44 | ||
78 | #define R_VERT_RAM_ADDR_POS 0x45 | ||
79 | |||
80 | /* Flip Flag */ | ||
81 | #define R_ENTRY_MODE_HORZ_NORMAL 0x7030 | ||
82 | #define R_ENTRY_MODE_HORZ_FLIPPED 0x7000 | ||
83 | static unsigned short r_entry_mode = R_ENTRY_MODE_HORZ_NORMAL; | ||
84 | #define R_ENTRY_MODE_VERT 0x7038 | ||
85 | #define R_ENTRY_MODE_SOLID_VERT 0x1038 | ||
86 | /* FIXME */ | ||
87 | #define R_ENTRY_MODE_VIDEO_NORMAL 0x7038 | ||
88 | #define R_ENTRY_MODE_VIDEO_FLIPPED 0x7018 | ||
89 | |||
90 | /* Reverse Flag */ | ||
91 | #define R_DISP_CONTROL_NORMAL 0x0004 | ||
92 | #define R_DISP_CONTROL_REV 0x0000 | ||
93 | static unsigned short r_disp_control_rev = R_DISP_CONTROL_NORMAL; | ||
94 | |||
95 | static const int xoffset = 20; | ||
96 | |||
97 | static inline void lcd_delay(int x) | ||
98 | { | ||
99 | do { | ||
100 | asm volatile ("nop\n"); | ||
101 | } while (x--); | ||
102 | } | ||
103 | |||
104 | static void as3525_dbop_init(void) | ||
105 | { | ||
106 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; | ||
107 | |||
108 | DBOP_TIMPOL_01 = 0xe167e167; | ||
109 | DBOP_TIMPOL_23 = 0xe167006e; | ||
110 | |||
111 | /* short count: 16 | output data width: 16 | readstrobe line */ | ||
112 | DBOP_CTRL = (1<<18|1<<12|1<<3); | ||
113 | |||
114 | GPIOB_AFSEL = 0xfc; | ||
115 | GPIOC_AFSEL = 0xff; | ||
116 | |||
117 | DBOP_TIMPOL_23 = 0x6000e; | ||
118 | |||
119 | /* short count: 16|enable write|output data width: 16|read strobe line */ | ||
120 | DBOP_CTRL = (1<<18|1<<16|1<<12|1<<3); | ||
121 | DBOP_TIMPOL_01 = 0x6e167; | ||
122 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
123 | |||
124 | /* TODO: The OF calls some other functions here, but maybe not important */ | ||
125 | } | ||
126 | |||
127 | static void lcd_write_cmd(short cmd) | ||
128 | { | ||
129 | /* Write register */ | ||
130 | DBOP_TIMPOL_23 = 0xa167006e; | ||
131 | dbop_write_data(&cmd, 1); | ||
132 | |||
133 | lcd_delay(4); | ||
134 | |||
135 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
136 | } | ||
137 | |||
138 | static void lcd_write_reg(int reg, int value) | ||
139 | { | ||
140 | int16_t data = value; | ||
141 | |||
142 | lcd_write_cmd(reg); | ||
143 | dbop_write_data(&data, 1); | ||
144 | } | ||
145 | |||
146 | /*** hardware configuration ***/ | ||
147 | |||
148 | void lcd_set_contrast(int val) | ||
149 | { | ||
150 | (void)val; | ||
151 | } | ||
152 | |||
153 | void lcd_set_invert_display(bool yesno) | ||
154 | { | ||
155 | r_disp_control_rev = yesno ? R_DISP_CONTROL_REV : | ||
156 | R_DISP_CONTROL_NORMAL; | ||
157 | |||
158 | if (display_on) | ||
159 | { | ||
160 | lcd_write_reg(R_DISP_CONTROL1, 0x0013 | r_disp_control_rev); | ||
161 | } | ||
162 | |||
163 | } | ||
164 | |||
165 | #ifdef HAVE_LCD_FLIP | ||
166 | static bool display_flipped = false; | ||
167 | |||
168 | /* turn the display upside down */ | ||
169 | void lcd_set_flip(bool yesno) | ||
170 | { | ||
171 | display_flipped = yesno; | ||
172 | |||
173 | r_entry_mode = yesno ? R_ENTRY_MODE_HORZ_FLIPPED : | ||
174 | R_ENTRY_MODE_HORZ_NORMAL; | ||
175 | } | ||
176 | #endif | ||
177 | |||
178 | static void _display_on(void) | ||
179 | { | ||
180 | /* Initialise in the same way as the original firmare */ | ||
181 | |||
182 | lcd_write_reg(R_DISP_CONTROL1, 0); | ||
183 | lcd_write_reg(R_POWER_CONTROL4, 0); | ||
184 | |||
185 | lcd_write_reg(R_POWER_CONTROL2, 0x3704); | ||
186 | lcd_write_reg(0x14, 0x1a1b); | ||
187 | lcd_write_reg(R_POWER_CONTROL1, 0x3860); | ||
188 | lcd_write_reg(R_POWER_CONTROL4, 0x40); | ||
189 | |||
190 | lcd_write_reg(R_POWER_CONTROL4, 0x60); | ||
191 | |||
192 | lcd_write_reg(R_POWER_CONTROL4, 0x70); | ||
193 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, 277); | ||
194 | lcd_write_reg(R_DRV_WAVEFORM_CONTROL, (7<<8)); | ||
195 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | ||
196 | lcd_write_reg(R_DISP_CONTROL2, 0x01); | ||
197 | lcd_write_reg(R_FRAME_CYCLE_CONTROL, (1<<10)); | ||
198 | lcd_write_reg(R_EXT_DISP_IF_CONTROL, 0); | ||
199 | |||
200 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x40); | ||
201 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0687); | ||
202 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0306); | ||
203 | lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x104); | ||
204 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0585); | ||
205 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 255+66); | ||
206 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0687+128); | ||
207 | lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 259); | ||
208 | lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0); | ||
209 | lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0); | ||
210 | |||
211 | lcd_write_reg(R_1ST_SCR_DRV_POS, (LCD_WIDTH - 1)); | ||
212 | lcd_write_reg(R_2ND_SCR_DRV_POS, 0); | ||
213 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH - 1)); | ||
214 | lcd_write_reg(R_VERT_RAM_ADDR_POS, 0); | ||
215 | lcd_write_reg(0x46, (((LCD_WIDTH - 1) + xoffset) << 8) | xoffset); | ||
216 | lcd_write_reg(0x47, (LCD_HEIGHT - 1)); | ||
217 | lcd_write_reg(0x48, 0x0); | ||
218 | |||
219 | lcd_write_reg(R_DISP_CONTROL1, 0x11); | ||
220 | lcd_write_reg(R_DISP_CONTROL1, 0x13 | r_disp_control_rev); | ||
221 | |||
222 | display_on = true; /* must be done before calling lcd_update() */ | ||
223 | lcd_update(); | ||
224 | } | ||
225 | |||
226 | void lcd_init_device(void) | ||
227 | { | ||
228 | as3525_dbop_init(); | ||
229 | |||
230 | GPIOA_DIR |= (1<<5|1<<4|1<<3); | ||
231 | GPIOA_PIN(5) = 0; | ||
232 | GPIOA_PIN(3) = (1<<3); | ||
233 | GPIOA_PIN(4) = 0; | ||
234 | GPIOA_PIN(5) = (1<<5); | ||
235 | |||
236 | _display_on(); | ||
237 | } | ||
238 | |||
239 | #if defined(HAVE_LCD_ENABLE) | ||
240 | void lcd_enable(bool on) | ||
241 | { | ||
242 | if (display_on == on) | ||
243 | return; | ||
244 | |||
245 | if(on) | ||
246 | { | ||
247 | lcd_write_reg(R_START_OSC, 1); | ||
248 | lcd_write_reg(R_POWER_CONTROL1, 0); | ||
249 | lcd_write_reg(R_POWER_CONTROL2, 0x3704); | ||
250 | lcd_write_reg(0x14, 0x1a1b); | ||
251 | lcd_write_reg(R_POWER_CONTROL1, 0x3860); | ||
252 | lcd_write_reg(R_POWER_CONTROL4, 0x40); | ||
253 | lcd_write_reg(R_POWER_CONTROL4, 0x60); | ||
254 | lcd_write_reg(R_POWER_CONTROL4, 112); | ||
255 | lcd_write_reg(R_DISP_CONTROL1, 0x11); | ||
256 | lcd_write_reg(R_DISP_CONTROL1, 0x13 | r_disp_control_rev); | ||
257 | display_on = true; | ||
258 | lcd_update(); /* Resync display */ | ||
259 | send_event(LCD_EVENT_ACTIVATION, NULL); | ||
260 | sleep(0); | ||
261 | |||
262 | } | ||
263 | else | ||
264 | { | ||
265 | lcd_write_reg(R_DISP_CONTROL1, 0x22); | ||
266 | lcd_write_reg(R_DISP_CONTROL1, 0); | ||
267 | lcd_write_reg(R_POWER_CONTROL1, 1); | ||
268 | display_on = false; | ||
269 | } | ||
270 | } | ||
271 | #endif | ||
272 | |||
273 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
274 | bool lcd_active(void) | ||
275 | { | ||
276 | return display_on; | ||
277 | } | ||
278 | #endif | ||
279 | |||
280 | /*** update functions ***/ | ||
281 | |||
282 | /* FIXME : find the datasheet for this RENESAS controller so we identify the | ||
283 | * registers used in windowing code (not present in HD66789R) */ | ||
284 | |||
285 | /* Set horizontal window addresses */ | ||
286 | static void lcd_window_x(int xmin, int xmax) | ||
287 | { | ||
288 | xmin += xoffset; | ||
289 | xmax += xoffset; | ||
290 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS + 2, (xmax << 8) | xmin); | ||
291 | lcd_write_reg(R_RAM_ADDR_SET - 1, xmin); | ||
292 | } | ||
293 | |||
294 | /* Set vertical window addresses */ | ||
295 | static void lcd_window_y(int ymin, int ymax) | ||
296 | { | ||
297 | lcd_write_reg(R_VERT_RAM_ADDR_POS + 2, ymax); | ||
298 | lcd_write_reg(R_VERT_RAM_ADDR_POS + 3, ymin); | ||
299 | lcd_write_reg(R_RAM_ADDR_SET, ymin); | ||
300 | } | ||
301 | |||
302 | static unsigned lcd_yuv_options = 0; | ||
303 | |||
304 | void lcd_yuv_set_options(unsigned options) | ||
305 | { | ||
306 | lcd_yuv_options = options; | ||
307 | } | ||
308 | |||
309 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
310 | extern void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
311 | int width, | ||
312 | int stride); | ||
313 | extern void lcd_write_yuv420_lines_odither(unsigned char const * const src[3], | ||
314 | int width, | ||
315 | int stride, | ||
316 | int x_screen, /* To align dither pattern */ | ||
317 | int y_screen); | ||
318 | |||
319 | /* Performance function to blit a YUV bitmap directly to the LCD | ||
320 | * src_x, src_y, width and height should be even | ||
321 | * x, y, width and height have to be within LCD bounds | ||
322 | */ | ||
323 | void lcd_blit_yuv(unsigned char * const src[3], | ||
324 | int src_x, int src_y, int stride, | ||
325 | int x, int y, int width, int height) | ||
326 | { | ||
327 | unsigned char const * yuv_src[3]; | ||
328 | off_t z; | ||
329 | |||
330 | /* Sorry, but width and height must be >= 2 or else */ | ||
331 | width &= ~1; | ||
332 | height >>= 1; | ||
333 | |||
334 | z = stride*src_y; | ||
335 | yuv_src[0] = src[0] + z + src_x; | ||
336 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
337 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
338 | |||
339 | #ifdef HAVE_LCD_FLIP | ||
340 | lcd_write_reg(R_ENTRY_MODE, | ||
341 | display_flipped ? R_ENTRY_MODE_VIDEO_FLIPPED : R_ENTRY_MODE_VIDEO_NORMAL | ||
342 | ); | ||
343 | #else | ||
344 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VIDEO_NORMAL); | ||
345 | #endif | ||
346 | |||
347 | lcd_window_x(x, x + width - 1); | ||
348 | |||
349 | if (lcd_yuv_options & LCD_YUV_DITHER) | ||
350 | { | ||
351 | do | ||
352 | { | ||
353 | lcd_window_y(y, y + 1); | ||
354 | |||
355 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
356 | |||
357 | lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y); | ||
358 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
359 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
360 | yuv_src[2] += stride >> 1; | ||
361 | y += 2; | ||
362 | } | ||
363 | while (--height > 0); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | do | ||
368 | { | ||
369 | lcd_window_y(y, y + 1); | ||
370 | |||
371 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
372 | |||
373 | lcd_write_yuv420_lines(yuv_src, width, stride); | ||
374 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
375 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
376 | yuv_src[2] += stride >> 1; | ||
377 | y += 2; | ||
378 | } | ||
379 | while (--height > 0); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | /* Update the display. | ||
384 | This must be called after all other LCD functions that change the display. */ | ||
385 | void lcd_update(void) | ||
386 | { | ||
387 | if (!display_on) | ||
388 | return; | ||
389 | |||
390 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | ||
391 | |||
392 | lcd_window_x(0, LCD_WIDTH - 1); | ||
393 | lcd_window_y(0, LCD_HEIGHT - 1); | ||
394 | |||
395 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
396 | |||
397 | dbop_write_data((fb_data*)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); | ||
398 | } | ||
399 | |||
400 | /* Update a fraction of the display. */ | ||
401 | void lcd_update_rect(int x, int y, int width, int height) | ||
402 | { | ||
403 | const fb_data *ptr; | ||
404 | |||
405 | if (!display_on) | ||
406 | return; | ||
407 | |||
408 | /* nothing to draw? */ | ||
409 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || | ||
410 | (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) | ||
411 | return; | ||
412 | |||
413 | if (x < 0) | ||
414 | { /* clip left */ | ||
415 | width += x; | ||
416 | x = 0; | ||
417 | } | ||
418 | if (y < 0) | ||
419 | { /* clip top */ | ||
420 | height += y; | ||
421 | y = 0; | ||
422 | } | ||
423 | if (x + width > LCD_WIDTH) | ||
424 | width = LCD_WIDTH - x; /* clip right */ | ||
425 | if (y + height > LCD_HEIGHT) | ||
426 | height = LCD_HEIGHT - y; /* clip bottom */ | ||
427 | |||
428 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | ||
429 | |||
430 | /* we need to make x and width even to enable 32bit transfers */ | ||
431 | width = (width + (x & 1) + 1) & ~1; | ||
432 | x &= ~1; | ||
433 | |||
434 | lcd_window_x(x, x + width - 1); | ||
435 | lcd_window_y(y, y + height -1); | ||
436 | |||
437 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
438 | |||
439 | ptr = &lcd_framebuffer[y][x]; | ||
440 | |||
441 | do | ||
442 | { | ||
443 | dbop_write_data(ptr, width); | ||
444 | ptr += LCD_WIDTH; | ||
445 | } | ||
446 | while (--height > 0); | ||
447 | } | ||
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/powermgmt-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/powermgmt-fuzev2.c new file mode 100644 index 0000000000..d0d39912f2 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-fuzev2/powermgmt-fuzev2.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2008 Rafaël Carré | ||
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 | |||
24 | /* The battery manufacturer's website shows discharge curves down to 3.0V, | ||
25 | so 'dangerous' and 'shutoff' levels of 3.4V and 3.3V should be safe. | ||
26 | */ | ||
27 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
28 | { | ||
29 | 3400 | ||
30 | }; | ||
31 | |||
32 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
33 | { | ||
34 | 3300 | ||
35 | }; | ||
36 | |||
37 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
38 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
39 | { | ||
40 | /* TODO: simple linear uncalibrated curve */ | ||
41 | { 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 } | ||
42 | }; | ||
43 | |||
44 | #if CONFIG_CHARGING | ||
45 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
46 | const unsigned short percent_to_volt_charge[11] = | ||
47 | { | ||
48 | /* TODO: simple linear uncalibrated curve */ | ||
49 | 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 | ||
50 | }; | ||
51 | #endif /* CONFIG_CHARGING */ | ||
52 | |||
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index db01da426b..16c89b9a7a 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c | |||
@@ -206,7 +206,7 @@ static void sdram_init(void) | |||
206 | #define MEMORY_MODEL 0x21 | 206 | #define MEMORY_MODEL 0x21 |
207 | 207 | ||
208 | #elif defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_CLIPV2) \ | 208 | #elif defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_CLIPV2) \ |
209 | || defined(SANSA_CLIPPLUS) | 209 | || defined(SANSA_CLIPPLUS) || defined(SANSA_FUZEV2) |
210 | /* 16 bits external bus, high performance SDRAM, 64 Mbits = 8 Mbytes */ | 210 | /* 16 bits external bus, high performance SDRAM, 64 Mbits = 8 Mbytes */ |
211 | #define MEMORY_MODEL 0x5 | 211 | #define MEMORY_MODEL 0x5 |
212 | 212 | ||