summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-11-01 10:29:23 +0000
committerDave Chapman <dave@dchapman.com>2008-11-01 10:29:23 +0000
commit74c75e5c047c772a5539554156f079d2a003fe4a (patch)
tree356c73c00c985c534864a4c9a6e8d3414b2a30fd
parent88806c0b1b3900b2cdcd8c28901bece2b05d4610 (diff)
downloadrockbox-74c75e5c047c772a5539554156f079d2a003fe4a.tar.gz
rockbox-74c75e5c047c772a5539554156f079d2a003fe4a.zip
Add Sansa Fuze to the build system, including a first (untested) attempt at an LCD driver. Lots of things are just copied from the e200v2, so this code needs testing, and then drivers properly merged if they prove to be the same.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18957 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/SOURCES9
-rw-r--r--firmware/export/config-fuze.h205
-rw-r--r--firmware/export/config.h4
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/adc-target.h24
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/backlight-fuze.c73
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/backlight-target.h32
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/button-fuze.c98
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/button-target.h62
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c449
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/system-target.h28
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/timer-target.h38
-rw-r--r--firmware/target/arm/as3525/system-as3525.c2
-rwxr-xr-xtools/configure22
-rw-r--r--tools/scramble.c4
14 files changed, 1048 insertions, 2 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 36ee9e4cb4..724f0920cf 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1067,6 +1067,15 @@ target/arm/as3525/as3525-codec.c
1067#endif /* !SIMULATOR */ 1067#endif /* !SIMULATOR */
1068#endif /* SANSA_M200V2 */ 1068#endif /* SANSA_M200V2 */
1069 1069
1070#ifdef SANSA_FUZE
1071#ifndef SIMULATOR
1072target/arm/as3525/sansa-fuze/button-fuze.c
1073target/arm/as3525/sansa-fuze/lcd-fuze.c
1074target/arm/as3525/sansa-e200v2/backlight-e200v2.c
1075target/arm/as3525/as3525-codec.c
1076#endif /* !SIMULATOR */
1077#endif /* SANSA_FUZE */
1078
1070#ifdef IAUDIO_7 1079#ifdef IAUDIO_7
1071#ifndef SIMULATOR 1080#ifndef SIMULATOR
1072drivers/nand_id.c 1081drivers/nand_id.c
diff --git a/firmware/export/config-fuze.h b/firmware/export/config-fuze.h
new file mode 100644
index 0000000000..d9aac46a14
--- /dev/null
+++ b/firmware/export/config-fuze.h
@@ -0,0 +1,205 @@
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 43
8#define MODEL_NAME "Sandisk Sansa Fuze"
9
10#define HW_SAMPR_CAPS (SAMPR_CAP_44)
11
12/* define this if you have recording possibility */
13#define HAVE_RECORDING
14
15#define REC_SAMPR_CAPS (SAMPR_CAP_22)
16#define REC_FREQ_DEFAULT REC_FREQ_22 /* Default is not 44.1kHz */
17#define REC_SAMPR_DEFAULT SAMPR_22
18
19/* Define bitmask of input sources - recordable bitmask can be defined
20 explicitly if different */
21#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO)
22
23/* define this if you have a bitmap LCD display */
24#define HAVE_LCD_BITMAP
25
26/* define this if you have a colour LCD */
27#define HAVE_LCD_COLOR
28
29/* define this if you want album art for this target */
30#define HAVE_ALBUMART
31
32/* define this if you have a light associated with the buttons */
33#define HAVE_BUTTON_LIGHT
34
35/* define this if you have access to the quickscreen */
36#define HAVE_QUICKSCREEN
37
38/* define this if you have access to the pitchscreen */
39#define HAVE_PITCHSCREEN
40
41/* define this if you would like tagcache to build on this target */
42#define HAVE_TAGCACHE
43
44/* LCD dimensions */
45#define LCD_WIDTH 220
46#define LCD_HEIGHT 176
47#define LCD_DEPTH 16 /* 65536 colours */
48#define LCD_PIXELFORMAT RGB565 /* rgb565 */
49
50#ifndef BOOTLOADER
51/* define this if you have LCD enable function */
52#define HAVE_LCD_ENABLE
53
54/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
55 should be defined as well. */
56#define HAVE_LCD_SLEEP
57#define HAVE_LCD_SLEEP_SETTING
58#endif
59
60/* define this if you can flip your LCD */
61#define HAVE_LCD_FLIP
62
63/* define this if you can invert the colours on your LCD */
64#define HAVE_LCD_INVERT
65
66/* #define IRAM_LCDFRAMEBUFFER IDATA_ATTR *//* put the lcd frame buffer in IRAM */
67
68#define CONFIG_KEYPAD SANSA_FUZE_PAD
69
70/* Define this if you do software codec */
71#define CONFIG_CODEC SWCODEC
72
73/* There is no hardware tone control */
74#define HAVE_SW_TONE_CONTROLS
75
76/* We're working on the assumption that the AS3525 has something
77 similar to the AS3514 for audio codec etc */
78#define HAVE_AS3514
79
80/* define this if you have a real-time clock */
81#ifndef BOOTLOADER
82#define CONFIG_RTC RTC_AS3525
83#endif
84
85/* Define this if you have a software controlled poweroff */
86#define HAVE_SW_POWEROFF
87
88/* Some Sansa E200s seem to be FAT16 formatted */
89#define HAVE_FAT16SUPPORT
90
91/* The number of bytes reserved for loadable codecs */
92#define CODEC_SIZE 0x100000
93
94/* The number of bytes reserved for loadable plugins */
95#define PLUGIN_BUFFER_SIZE 0x80000
96
97#define AB_REPEAT_ENABLE 1
98
99/* FM Tuner - suspected to be the SI4702, but use SI4700 for now */
100#define CONFIG_TUNER SI4700
101/* #define HAVE_TUNER_PWR_CTRL */
102
103/* Define this for LCD backlight available */
104#define HAVE_BACKLIGHT
105#define HAVE_BACKLIGHT_BRIGHTNESS
106
107/* define this if the unit uses a scrollwheel for navigation */
108#define HAVE_SCROLLWHEEL
109/* define from which rotation speed [degree/sec] on the acceleration starts */
110#define WHEEL_ACCEL_START 540
111/* define type of acceleration (1 = ^2, 2 = ^3, 3 = ^4) */
112#define WHEEL_ACCELERATION 1
113
114/* define this if you have a flash memory storage */
115#define HAVE_FLASH_STORAGE
116
117/* define this if the flash memory uses the SecureDigital Memory Card protocol */
118#define CONFIG_STORAGE STORAGE_SD
119
120#define BATTERY_CAPACITY_DEFAULT 750 /* default battery capacity */
121#define BATTERY_CAPACITY_MIN 750 /* min. capacity selectable */
122#define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */
123#define BATTERY_CAPACITY_INC 0 /* capacity increment */
124#define BATTERY_TYPES_COUNT 1 /* only one type */
125
126/* Hardware controlled charging? FIXME */
127#define CONFIG_CHARGING CHARGING_SIMPLE
128
129/* define this if the unit can be powered or charged via USB */
130#define HAVE_USB_POWER
131
132/** Non-simulator section **/
133#ifndef SIMULATOR
134
135/* Define this if you have an AMS AS3525*/
136#define CONFIG_CPU AS3525
137
138/* Define this if you want to use the AS2525 i2c interface */
139#define CONFIG_I2C I2C_AS3525
140
141/* define this if the hardware can be powered off while charging */
142/* Sansa can't be powered off while charging */
143/* #define HAVE_POWEROFF_WHILE_CHARGING */
144
145/* The start address index for ROM builds */
146#define ROM_START 0x00000000
147
148/* Define this to the CPU frequency */
149#define CPU_FREQ 75000000
150
151/* Type of LCD */
152#define CONFIG_LCD LCD_FUZE
153
154/* Offset ( in the firmware file's header ) to the file CRC and data. These are
155 only used when loading the old format rockbox.e200 file */
156#define FIRMWARE_OFFSET_FILE_CRC 0x0
157#define FIRMWARE_OFFSET_FILE_DATA 0x8
158
159#ifndef BOOTLOADER
160#define HAVE_MULTIVOLUME
161#define HAVE_HOTSWAP
162#endif
163
164/* #define USB_IPODSTYLE */
165
166/* USB On-the-go */
167#define CONFIG_USBOTG USBOTG_AS3525
168
169/* enable these for the experimental usb stack */
170//#define HAVE_USBSTACK
171#define USB_VENDOR_ID 0x0781
172#define USB_PRODUCT_ID 0x7423
173
174/* Virtual LED (icon) */
175#define CONFIG_LED LED_VIRTUAL
176
177/* Define this if you have adjustable CPU frequency */
178#define HAVE_ADJUSTABLE_CPU_FREQ
179
180#define BOOTFILE_EXT "sansa"
181#define BOOTFILE "rockbox." BOOTFILE_EXT
182#define BOOTDIR "/.rockbox"
183
184#define ICODE_ATTR_TREMOR_NOT_MDCT
185
186#define INCLUDE_TIMEOUT_API
187
188#endif /* SIMULATOR */
189
190/** Port-specific settings **/
191
192/* Main LCD backlight brightness range and defaults */
193#define MIN_BRIGHTNESS_SETTING 1
194#define MAX_BRIGHTNESS_SETTING 12
195#define DEFAULT_BRIGHTNESS_SETTING 6
196
197/* Default recording levels */
198#define DEFAULT_REC_MIC_GAIN 23
199#define DEFAULT_REC_LEFT_GAIN 23
200#define DEFAULT_REC_RIGHT_GAIN 23
201
202#ifdef E200R_INSTALLER
203#define IRAMORIG 0x40004000
204#endif
205
diff --git a/firmware/export/config.h b/firmware/export/config.h
index c12f6ce4d2..0867efda45 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -105,6 +105,7 @@
105#define MEIZU_M6SP_PAD 33 105#define MEIZU_M6SP_PAD 33
106#define MEIZU_M3_PAD 34 106#define MEIZU_M3_PAD 34
107#define SANSA_CLIP_PAD 35 107#define SANSA_CLIP_PAD 35
108#define SANSA_FUZE_PAD 36
108 109
109/* CONFIG_REMOTE_KEYPAD */ 110/* CONFIG_REMOTE_KEYPAD */
110#define H100_REMOTE 1 111#define H100_REMOTE 1
@@ -150,6 +151,7 @@
150#define LCD_ONDAVX747 29 /* as used by the Onda VX747 */ 151#define LCD_ONDAVX747 29 /* as used by the Onda VX747 */
151#define LCD_ONDAVX767 30 /* as used by the Onda VX767 */ 152#define LCD_ONDAVX767 30 /* as used by the Onda VX767 */
152#define LCD_SSD1303 31 /* as used by the Sansa Clip */ 153#define LCD_SSD1303 31 /* as used by the Sansa Clip */
154#define LCD_FUZE 32 /* as used by the Sansa Fuze */
153 155
154/* LCD_PIXELFORMAT */ 156/* LCD_PIXELFORMAT */
155#define HORIZONTAL_PACKING 1 157#define HORIZONTAL_PACKING 1
@@ -320,6 +322,8 @@
320#include "config-e200v2.h" 322#include "config-e200v2.h"
321#elif defined(SANSA_M200V2) 323#elif defined(SANSA_M200V2)
322#include "config-m200v2.h" 324#include "config-m200v2.h"
325#elif defined(SANSA_FUZE)
326#include "config-fuze.h"
323#else 327#else
324/* no known platform */ 328/* no known platform */
325#endif 329#endif
diff --git a/firmware/target/arm/as3525/sansa-fuze/adc-target.h b/firmware/target/arm/as3525/sansa-fuze/adc-target.h
new file mode 100644
index 0000000000..bea0272496
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/adc-target.h
@@ -0,0 +1,24 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 ??
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 _ADC_TARGET_H_
22#define _ADC_TARGET_H_
23
24#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/as3525/sansa-fuze/backlight-fuze.c b/firmware/target/arm/as3525/sansa-fuze/backlight-fuze.c
new file mode 100644
index 0000000000..735b85667d
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/backlight-fuze.c
@@ -0,0 +1,73 @@
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#include "config.h"
22#include "backlight-target.h"
23#include "system.h"
24#include "lcd.h"
25#include "backlight.h"
26#include "as3525-codec.h"
27#include "as3514.h"
28
29static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
30
31void _backlight_set_brightness(int brightness)
32{
33 backlight_brightness = brightness;
34
35 if (brightness > 0)
36 _backlight_on();
37 else
38 _backlight_off();
39}
40
41void _backlight_on(void)
42{
43#ifdef HAVE_LCD_SLEEP
44 backlight_lcd_sleep_countdown(false); /* stop counter */
45#endif
46#ifdef HAVE_LCD_ENABLE
47 lcd_enable(true); /* power on lcd + visible display */
48#endif
49 as3525_codec_write(AS3514_DCDC15, backlight_brightness);
50}
51
52void _backlight_off(void)
53{
54 as3525_codec_write(AS3514_DCDC15, 0x0);
55#ifdef HAVE_LCD_ENABLE
56 lcd_enable(false); /* power off visible display */
57#endif
58#ifdef HAVE_LCD_SLEEP
59 backlight_lcd_sleep_countdown(true); /* start countdown */
60#endif
61}
62
63void _buttonlight_on(void)
64{
65 GPIOD_PIN(7) = (1<<7);
66 GPIOD_DIR |= (1<<7);
67}
68
69void _buttonlight_off(void)
70{
71 GPIOD_PIN(7) = 0;
72 GPIOD_DIR |= (1<<7);
73}
diff --git a/firmware/target/arm/as3525/sansa-fuze/backlight-target.h b/firmware/target/arm/as3525/sansa-fuze/backlight-target.h
new file mode 100644
index 0000000000..db2cecc07a
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/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
25void _backlight_on(void);
26void _backlight_off(void);
27void _backlight_set_brightness(int brightness);
28int __backlight_is_on(void);
29
30void _buttonlight_on(void);
31void _buttonlight_off(void);
32#endif
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
new file mode 100644
index 0000000000..fc2715216c
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
@@ -0,0 +1,98 @@
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/* Taken from button-h10.c by Barry Wardell and reverse engineering by MrH. */
23
24#include "system.h"
25#include "button.h"
26#include "backlight.h"
27#include "powermgmt.h"
28
29#define WHEEL_REPEAT_INTERVAL 300000
30#define WHEEL_FAST_ON_INTERVAL 20000
31#define WHEEL_FAST_OFF_INTERVAL 60000
32#define WHEELCLICKS_PER_ROTATION 48 /* wheelclicks per full rotation */
33
34/* Clickwheel */
35#ifndef BOOTLOADER
36static unsigned int old_wheel_value = 0;
37static unsigned int wheel_repeat = BUTTON_NONE;
38static unsigned int wheel_click_count = 0;
39static unsigned int wheel_delta = 0;
40static int wheel_fast_mode = 0;
41static unsigned long last_wheel_usec = 0;
42static unsigned long wheel_velocity = 0;
43static long last_wheel_post = 0;
44static long next_backlight_on = 0;
45/* Buttons */
46static bool hold_button = false;
47static bool hold_button_old = false;
48#define _button_hold() hold_button
49#else
50#define _button_hold() false /* FIXME */
51#endif /* BOOTLOADER */
52static int int_btn = BUTTON_NONE;
53
54void button_init_device(void)
55{
56}
57
58bool button_hold(void)
59{
60 return _button_hold();
61}
62
63/* clickwheel */
64#ifndef BOOTLOADER
65void clickwheel_int(void)
66{
67}
68#endif /* BOOTLOADER */
69
70/* device buttons */
71void button_int(void)
72{
73 unsigned char state;
74
75 int_btn = BUTTON_NONE;
76
77}
78
79/*
80 * Get button pressed from hardware
81 */
82int button_read_device(void)
83{
84#ifdef BOOTLOADER
85 /* Read buttons directly in the bootloader */
86 button_int();
87#else
88 /* light handling */
89 if (hold_button != hold_button_old)
90 {
91 hold_button_old = hold_button;
92 backlight_hold_changed(hold_button);
93 }
94#endif /* BOOTLOADER */
95
96 /* The int_btn variable is set in the button interrupt handler */
97 return int_btn;
98}
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-target.h b/firmware/target/arm/as3525/sansa-fuze/button-target.h
new file mode 100644
index 0000000000..c818c602d0
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/button-target.h
@@ -0,0 +1,62 @@
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
30bool button_hold(void);
31void button_init_device(void);
32int button_read_device(void);
33#ifndef BOOTLOADER
34void clickwheel_int(void);
35#endif
36void button_int(void);
37
38/* Sandisk Sansa Fuze button codes */
39
40/* TODO: These are just a copy of the E200 */
41
42/* Main unit's buttons */
43#define BUTTON_REC 0x00000001
44#define BUTTON_DOWN 0x00000002
45#define BUTTON_RIGHT 0x00000004
46#define BUTTON_LEFT 0x00000008
47#define BUTTON_SELECT 0x00000010
48#define BUTTON_UP 0x00000020
49#define BUTTON_POWER 0x00000040
50
51#define BUTTON_SCROLL_BACK 0x00000080
52#define BUTTON_SCROLL_FWD 0x00000100
53
54#define BUTTON_MAIN 0x00000fff
55
56/* No Remote control */
57#define BUTTON_REMOTE 0
58
59#define POWEROFF_BUTTON BUTTON_POWER
60#define POWEROFF_COUNT 10
61
62#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
new file mode 100644
index 0000000000..ff62949dcd
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
@@ -0,0 +1,449 @@
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
28static bool display_on = false; /* is the display turned on? */
29static bool display_flipped = false;
30static int xoffset = 20; /* needed for flip */
31
32/* TODO: Implement this function */
33static void lcd_delay(int x)
34{
35 /* This is just arbitrary - the OF does something more complex */
36 x *= 1024;
37 while (x--);
38}
39
40static void as3525_dbop_init(void)
41{
42 CGU_DBOP = (1<<3) | (4-1);
43
44 DBOP_TIMPOL_01 = 0xe167e167;
45 DBOP_TIMPOL_23 = 0xe167006e;
46 DBOP_CTRL = 0x41008;
47
48 GPIOB_AFSEL = 0xfc;
49 GPIOC_AFSEL = 0xff;
50
51 DBOP_TIMPOL_23 = 0x6000e;
52 DBOP_CTRL = 0x51008;
53 DBOP_TIMPOL_01 = 0x6e167;
54 DBOP_TIMPOL_23 = 0xa167e06f;
55
56 /* TODO: The OF calls some other functions here, but maybe not important */
57}
58
59static void lcd_write_cmd(int cmd)
60{
61 int x;
62
63 /* Write register */
64 DBOP_CTRL &= ~(1<<14);
65
66 DBOP_TIMPOL_23 = 0xa167006e;
67
68 DBOP_DOUT = cmd;
69
70 /* Wait for fifo to empty */
71 while ((DBOP_STAT & (1<<10)) == 0);
72
73 /* This loop is unique to the Fuze */
74 x = 0;
75 do {
76 asm volatile ("nop\n");
77 } while (x++ < 4);
78
79
80 DBOP_TIMPOL_23 = 0xa167e06f;
81}
82
83void lcd_write_data(const fb_data* p_bytes, int count)
84{
85 while (count--)
86 {
87 DBOP_DOUT = *p_bytes++;
88
89 /* Wait for fifo to empty */
90 while ((DBOP_STAT & (1<<10)) == 0);
91 }
92}
93
94static void lcd_write_reg(int reg, int value)
95{
96 unsigned short data = value;
97
98 lcd_write_cmd(reg);
99 lcd_write_data(&data, 1);
100}
101
102/*** hardware configuration ***/
103
104void lcd_set_contrast(int val)
105{
106 (void)val;
107}
108
109void lcd_set_invert_display(bool yesno)
110{
111 (void)yesno;
112}
113
114static void flip_lcd(bool yesno)
115{
116 (void)yesno;
117}
118
119
120/* turn the display upside down (call lcd_update() afterwards) */
121void lcd_set_flip(bool yesno)
122{
123 display_flipped = yesno;
124 xoffset = yesno ? 20 : 0; /* A guess */
125
126 if (display_on)
127 flip_lcd(yesno);
128}
129
130
131static void _display_on(void)
132{
133 /* Initialise in the same way as the original firmare */
134
135 lcd_write_reg(0x07, 0);
136 lcd_write_reg(0x13, 0);
137
138 lcd_delay(10);
139
140 lcd_write_reg(0x11, 0x3704);
141 lcd_write_reg(0x14, 0x1a1b);
142 lcd_write_reg(0x10, 0x3860);
143 lcd_write_reg(0x13, 0x40);
144
145 lcd_delay(10);
146
147 lcd_write_reg(0x13, 0x60);
148
149 lcd_delay(50);
150
151 lcd_write_reg(0x13, 0x70);
152
153 lcd_delay(40);
154
155 lcd_write_reg(0x01, 277);
156 lcd_write_reg(0x02, (7<<8));
157 lcd_write_reg(0x03, 0x30);
158 lcd_write_reg(0x08, 0x01);
159 lcd_write_reg(0x0b, (1<<10));
160 lcd_write_reg(0x0c, 0);
161
162 lcd_write_reg(0x30, 0x40);
163 lcd_write_reg(0x31, 0x0687);
164 lcd_write_reg(0x32, 0x0306);
165 lcd_write_reg(0x33, 0x104);
166 lcd_write_reg(0x34, 0x0585);
167 lcd_write_reg(0x35, 255+66);
168 lcd_write_reg(0x36, 0x0687+128);
169 lcd_write_reg(0x37, 259);
170 lcd_write_reg(0x38, 0);
171 lcd_write_reg(0x39, 0);
172
173 lcd_write_reg(0x42, (LCD_WIDTH - 1));
174 lcd_write_reg(0x43, 0);
175 lcd_write_reg(0x44, (LCD_WIDTH - 1));
176 lcd_write_reg(0x45, 0);
177 lcd_write_reg(0x46, (((LCD_WIDTH - 1) + xoffset) << 8) | xoffset);
178 lcd_write_reg(0x47, (LCD_HEIGHT - 1));
179 lcd_write_reg(0x48, 0x0);
180
181 lcd_write_reg(0x07, 0x11);
182
183 lcd_delay(40);
184
185 lcd_write_reg(0x07, 0x17);
186
187 display_on = true; /* must be done before calling lcd_update() */
188 lcd_update();
189}
190
191/* (e.g. 0, 219) */
192static void lcd_window_x(int r0, int r1)
193{
194 int r2, r3, r4;
195
196 r3 = (LCD_WIDTH - 1);
197 r2 = (LCD_WIDTH - 1);
198
199 if (r0 < LCD_WIDTH)
200 r2 = r0;
201
202 if (r1 < LCD_WIDTH)
203 r3 = r1;
204
205#if 0
206 r1 = 0x1db12;
207
208 [r1] = 1; /* byte */
209#endif
210
211 r3 += xoffset;
212
213 r4 = r2;
214
215 r4 += xoffset;
216
217 r0 = (r3 << 8);
218
219 r0 |= r4;
220
221 r1 = (r0 << 16) >> 16;
222
223 lcd_write_reg(0x46, r1);
224
225 r1 = (r4 << 16) >> 16;
226
227 lcd_write_reg(0x20, r1);
228
229 lcd_write_reg(0x03, 0x30);
230
231#if 0
232 r0 := 0x1e0c4
233 r1 := 0x216a8
234
235 r0 := [r0]
236 r2 := [r1]
237
238 r0 := (r0 >> 2) << 2;
239
240 if (r0 != r2) {
241#endif
242 lcd_write_reg(0x00, 0x0001);
243 lcd_write_reg(0x11, 0x3704);
244 lcd_write_reg(0x14, 0x1a1b);
245 lcd_write_reg(0x10, 0x3860);
246 lcd_write_reg(0x13, 0x0070);
247 lcd_write_reg(0x07, 0x0017);
248 lcd_write_reg(0x01, 277);
249 lcd_write_reg(0x02, (7<<8));
250 lcd_write_reg(0x08, 0x0001);
251 lcd_write_reg(0x0b, (1<<10));
252 lcd_write_reg(0x0c, 0x0000);
253 lcd_write_reg(0x30, 0x0040);
254 lcd_write_reg(0x31, 0x0687);
255 lcd_write_reg(0x32, 0x0306);
256 lcd_write_reg(0x33, 260);
257 lcd_write_reg(0x34, 0x0585);
258 lcd_write_reg(0x35, 255+66);
259 lcd_write_reg(0x36, 0x687+128);
260 lcd_write_reg(0x37, 259);
261 lcd_write_reg(0x38, 0);
262 lcd_write_reg(0x39, 0);
263 lcd_write_reg(0x40, 0);
264 lcd_write_reg(0x41, 0);
265 lcd_write_reg(0x42, (LCD_WIDTH - 1));
266 lcd_write_reg(0x43, 0);
267 lcd_write_reg(0x44, (LCD_WIDTH - 1));
268 lcd_write_reg(0x45, 0);
269 lcd_write_reg(0x15, 0);
270 lcd_write_reg(0x73, 0);
271#if 0
272 }
273#endif
274}
275
276/* - e.g. 0, 175 */
277static void lcd_window_y(int r0, int r1)
278{
279 int r2, r4;
280
281 r2 = (LCD_HEIGHT - 1);
282 r4 = (LCD_HEIGHT - 1);
283
284 if (r0 < LCD_HEIGHT)
285 r4 = r0;
286
287 if (r1 < LCD_HEIGHT)
288 r2 = r1;
289
290 r1 = (r2 << 16) >> 16;
291
292 lcd_write_reg(0x47, r1);
293
294 r1 = (r4 << 16) >> 16;
295
296 lcd_write_reg(0x48, r1);
297
298 /* ??Start address - (x<<8) | y0 */
299 lcd_write_reg(0x21, r1);
300
301 /* Start write to GRAM */
302 lcd_write_cmd(0x22);
303}
304
305/* I'm guessing this function is lcd_enable, but it may not be... */
306void lcd_enable(int r0)
307{
308#if 0
309 r4 = 0x1db12;
310 [r4] = 1;
311#endif
312
313 if (r0 != 0) {
314 lcd_write_reg(0, 1);
315
316 lcd_delay(10);
317
318 lcd_write_reg(0x10, 0);
319 lcd_write_reg(0x11, 0x3704);
320 lcd_write_reg(0x14, 0x1a1b);
321 lcd_write_reg(0x10, 0x3860);
322 lcd_write_reg(0x13, 0x40);
323
324 lcd_delay(10);
325
326 lcd_write_reg(0x13, 0x60);
327
328 lcd_delay(50);
329
330 lcd_write_reg(0x13, 112);
331
332 lcd_delay(40);
333
334 lcd_write_reg(0x07, 0x11);
335
336 lcd_delay(40);
337
338 lcd_write_reg(0x07, 0x17);
339 } else {
340 lcd_write_reg(0x07, 0x22);
341
342 lcd_delay(40);
343
344 lcd_write_reg(0x07, 0);
345
346 lcd_delay(40);
347
348 lcd_write_reg(0x10, 1);
349 }
350
351#if 0
352 [r4] = 0;
353#endif
354}
355
356void lcd_init_device()
357{
358 as3525_dbop_init();
359
360 GPIOA_DIR |= (1<<5);
361 GPIOA_PIN(5) = 0;
362
363 GPIOA_PIN(3) = (1<<3);
364
365 GPIOA_DIR |= (1<<4) | (1<<3);
366
367 GPIOA_PIN(3) = (1<<3);
368
369 GPIOA_PIN(4) = 0;
370
371 GPIOA_DIR |= (1<<7);
372 GPIOA_PIN(7) = 0;
373
374 CCU_IO &= ~4;
375 CCU_IO &= ~8;
376
377 GPIOD_DIR |= (1<<7);
378
379#if 0
380 if (byte[0x21b24] == 0) {
381 GPIOD_PIN(7) = (1<<7);
382 GPIOD_DIR |= (1<<7);
383 }
384#endif
385
386 lcd_delay(1);
387
388 GPIOA_PIN(5) = (1<<5);
389
390 lcd_delay(1);
391
392 _display_on();
393}
394
395/* Update the display.
396 This must be called after all other LCD functions that change the display. */
397void lcd_update(void)
398{
399 if (!display_on)
400 return;
401
402 lcd_window_x(0, (LCD_WIDTH - 1));
403
404 lcd_window_y(0, (LCD_HEIGHT - 1));
405
406 lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
407
408}
409
410/* Update a fraction of the display. */
411void lcd_update_rect(int x, int y, int width, int height)
412{
413 int xmax, ymax;
414 const unsigned short *ptr;
415
416 if (!display_on)
417 return;
418
419 xmax = x + width - 1;
420 if (xmax >= LCD_WIDTH)
421 xmax = LCD_WIDTH - 1; /* Clip right */
422 if (x < 0)
423 x = 0; /* Clip left */
424 if (x >= xmax)
425 return; /* nothing left to do */
426
427 ymax = y + height;
428 if (ymax > LCD_HEIGHT)
429 ymax = LCD_HEIGHT - 1; /* Clip bottom */
430 if (y < 0)
431 y = 0; /* Clip top */
432 if (y >= ymax)
433 return; /* nothing left to do */
434
435
436 lcd_window_x(x, xmax);
437 lcd_window_y(y, ymax);
438
439 ptr = (unsigned short *)&lcd_framebuffer[y][x];
440
441 do
442 {
443 lcd_write_data(ptr, width);
444 ptr += LCD_WIDTH;
445 }
446 while (++y < ymax);
447
448 lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
449}
diff --git a/firmware/target/arm/as3525/sansa-fuze/system-target.h b/firmware/target/arm/as3525/sansa-fuze/system-target.h
new file mode 100644
index 0000000000..b712d1c124
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/system-target.h
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 ??
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 SYSTEM_TARGET_H
22#define SYSTEM_TARGET_H
23
24#include "system-arm.h"
25
26#define CPUFREQ_MAX 250000000
27
28#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/as3525/sansa-fuze/timer-target.h b/firmware/target/arm/as3525/sansa-fuze/timer-target.h
new file mode 100644
index 0000000000..b81da57885
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuze/timer-target.h
@@ -0,0 +1,38 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 ??
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 TIMER_TARGET_H
22#define TIMER_TARGET_H
23
24bool __timer_set(long cycles, bool set);
25bool __timer_register(void);
26void __timer_unregister(void);
27
28#define __TIMER_SET(cycles, set) \
29 __timer_set(cycles, set)
30
31#define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \
32 int_prio, timer_callback) \
33 __timer_register()
34
35#define __TIMER_UNREGISTER(...) \
36 __timer_unregister()
37
38#endif /* TIMER_TARGET_H */
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
index e83e5150ae..ff0f892406 100644
--- a/firmware/target/arm/as3525/system-as3525.c
+++ b/firmware/target/arm/as3525/system-as3525.c
@@ -167,7 +167,7 @@ static void sdram_init(void)
167 MPMC_DYNAMIC_tRRD = 2; 167 MPMC_DYNAMIC_tRRD = 2;
168 MPMC_DYNAMIC_tMRD = 2; 168 MPMC_DYNAMIC_tMRD = 2;
169 169
170#if defined(SANSA_CLIP) || defined(SANSA_M200V2) 170#if defined(SANSA_CLIP) || defined(SANSA_M200V2) || defined(SANSA_FUZE)
171# define MEMORY_MODEL 0x21 171# define MEMORY_MODEL 0x21
172 /* 16 bits external bus, low power SDRAM, 16 Mbits = 2 Mbytes */ 172 /* 16 bits external bus, low power SDRAM, 16 Mbits = 2 Mbytes */
173#elif defined(SANSA_E200V2) 173#elif defined(SANSA_E200V2)
diff --git a/tools/configure b/tools/configure
index 41bd8c27c0..f657c7387e 100755
--- a/tools/configure
+++ b/tools/configure
@@ -696,6 +696,7 @@ cat <<EOF
696 55) Sansa Clip 696 55) Sansa Clip
697 56) Sansa e200v2 697 56) Sansa e200v2
698 57) Sansa m200v2 698 57) Sansa m200v2
699 58) Sansa Fuze
699 700
700 ==Tatung== ==Olympus== ==Logik== 701 ==Tatung== ==Olympus== ==Logik==
701 60) Elio TPJ-1022 70) M:Robe 500 80) DAX 1GB MP3/DAB 702 60) Elio TPJ-1022 70) M:Robe 500 80) DAX 1GB MP3/DAB
@@ -1742,6 +1743,27 @@ fi
1742 ;; 1743 ;;
1743 1744
1744 1745
1746 58|fuze)
1747 target_id=53
1748 modelname="fuze"
1749 target="-DSANSA_FUZE"
1750 memory=2
1751 arm9tdmicc
1752 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
1753 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
1754 tool="$rootdir/tools/scramble -add=e2v2"
1755 output="rockbox.sansa"
1756 bootoutput="bootloader-fuze.sansa"
1757 appextra="recorder:gui"
1758 plugins="yes"
1759 swcodec="yes"
1760 toolset=$scramblebitmaptools
1761 t_cpu="arm"
1762 t_manufacturer="as3525"
1763 t_model="sansa-fuze"
1764 ;;
1765
1766
1745 60|tpj1022) 1767 60|tpj1022)
1746 target_id=25 1768 target_id=25
1747 modelname="tpj1022" 1769 modelname="tpj1022"
diff --git a/tools/scramble.c b/tools/scramble.c
index 0cf16031a4..663899a178 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -122,7 +122,7 @@ void usage(void)
122 "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n" 122 "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n"
123 "\t ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n" 123 "\t ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n"
124 "\t tpj2, c200, e200, giga, gigs, m100, m500, d2,\n"); 124 "\t tpj2, c200, e200, giga, gigs, m100, m500, d2,\n");
125 printf("\t 9200, 1630, ldax, m200, clip, e2v2, m2v2)\n"); 125 printf("\t 9200, 1630, ldax, m200, clip, e2v2, m2v2, fuze)\n");
126 printf("\nNo option results in Archos standard player/recorder format.\n"); 126 printf("\nNo option results in Archos standard player/recorder format.\n");
127 127
128 exit(1); 128 exit(1);
@@ -291,6 +291,8 @@ int main (int argc, char** argv)
291 modelnum = 41; 291 modelnum = 41;
292 else if (!strcmp(&argv[1][5], "m2v2")) 292 else if (!strcmp(&argv[1][5], "m2v2"))
293 modelnum = 42; 293 modelnum = 42;
294 else if (!strcmp(&argv[1][5], "fuze"))
295 modelnum = 43;
294 else { 296 else {
295 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); 297 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
296 return 2; 298 return 2;