From 204c9b06d310fc2c4f2cf0fe0f595f60afbf7747 Mon Sep 17 00:00:00 2001
From: Bertrik Sikken <bertrik@sikken.nl>
Date: Sat, 29 Oct 2011 00:01:04 +0200
Subject: [PATCH] Clip zip port WIP
---
firmware/export/config/sansaclipzip.h | 8 +++++---
.../arm/as3525/sansa-clipzip/backlight-clipzip.c | 18 ++++++++----------
.../arm/as3525/sansa-clipzip/button-clipzip.c | 10 +++++-----
.../target/arm/as3525/sansa-clipzip/lcd-clipzip.c | 12 ++++++++++--
firmware/target/arm/as3525/sd-as3525v2.c | 17 +++++++----------
firmware/target/arm/as3525/system-as3525.c | 2 +-
firmware/target/arm/as3525/system-target.h | 2 +-
rbutil/mkamsboot/dualboot.c | 15 ++++++++-------
rbutil/mkamsboot/dualboot.h | 2 +-
rbutil/mkamsboot/dualboot/dualboot.S | 8 ++++++--
rbutil/mkamsboot/mkamsboot.c | 4 ++--
11 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/firmware/export/config/sansaclipzip.h b/firmware/export/config/sansaclipzip.h
index fcffbce..c40dc4b 100644
--- a/firmware/export/config/sansaclipzip.h
+++ b/firmware/export/config/sansaclipzip.h
@@ -45,7 +45,7 @@
#define LCD_WIDTH 96
#define LCD_HEIGHT 96
#define LCD_DEPTH 16 /* 65536 colours */
-#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 swapped */
+#define LCD_PIXELFORMAT RGB565
/* define this if you have LCD enable function */
#define HAVE_LCD_ENABLE
@@ -114,6 +114,8 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
/* define this if you have a flash memory storage */
#define HAVE_FLASH_STORAGE
@@ -189,8 +191,8 @@
/** Port-specific settings **/
/* Main LCD backlight brightness range and defaults */
-#define MIN_BRIGHTNESS_SETTING 1 /* TODO */
-#define MAX_BRIGHTNESS_SETTING 12 /* TODO */
+#define MIN_BRIGHTNESS_SETTING 0 /* TODO */
+#define MAX_BRIGHTNESS_SETTING 10 /* TODO */
#define DEFAULT_BRIGHTNESS_SETTING 6 /* TODO */
/* Default recording levels */
diff --git a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
index 758aa87..589f804 100644
--- a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
+++ b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
@@ -25,11 +25,14 @@
#include "lcd.h"
#include "as3525v2.h"
#include "ascodec-target.h"
+#include "lcd-target.h"
bool _backlight_init()
{
/* GPIO B1 controls backlight */
GPIOB_DIR |= (1 << 1);
+ ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
+ GPIOB_PIN(1) = (1 << 1);
return true;
}
@@ -37,13 +40,6 @@ bool _backlight_init()
void _backlight_on(void)
{
GPIOB_PIN(1) = (1 << 1);
-
- ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
- sleep(1);
- ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
- sleep(1);
- ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
-
#ifdef HAVE_LCD_ENABLE
lcd_enable(true);
#endif
@@ -54,9 +50,11 @@ void _backlight_off(void)
#ifdef HAVE_LCD_ENABLE
lcd_enable(false);
#endif
-
GPIOB_PIN(1) = 0;
-
- ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
+}
+
+void _backlight_set_brightness(int brightness)
+{
+ oled_brightness(brightness);
}
diff --git a/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c
index 104c227..e960b49 100644
--- a/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c
+++ b/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c
@@ -71,13 +71,13 @@ int button_read_device(void)
udelay(500);
if (GPIOC_PIN(3)) {
- buttons |= BUTTON_LEFT;
+ buttons |= BUTTON_RIGHT;
}
if (GPIOC_PIN(4)) {
buttons |= BUTTON_SELECT;
}
if (GPIOC_PIN(5)) {
- buttons |= BUTTON_RIGHT;
+ buttons |= BUTTON_UP;
}
/* key matrix buttons, second row */
@@ -86,13 +86,13 @@ int button_read_device(void)
udelay(500);
if (GPIOC_PIN(3)) {
- buttons |= BUTTON_UP;
+ buttons |= BUTTON_HOME;
}
if (GPIOC_PIN(4)) {
- buttons |= BUTTON_HOME;
+ buttons |= BUTTON_DOWN;
}
if (GPIOC_PIN(5)) {
- buttons |= BUTTON_DOWN;
+ buttons |= BUTTON_LEFT;
}
/* deselect scan rows */
diff --git a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
index 899eb53..929961d 100644
--- a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
+++ b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
@@ -51,12 +51,20 @@ static int lcd_hw_init(void)
SSP_IMSC &= ~0xF; /* disable interrupts */
SSP_DMACR &= ~0x3; /* disable DMA */
+ // ??
+ GPIOA_DIR |= (1 << 3);
+ GPIOA_PIN(3) = (1 << 3);
+ GPIOA_DIR |= (1 << 0);
+ GPIOA_PIN(0) = (1 << 0);
+ GPIOB_DIR |= (1 << 7);
+ GPIOB_PIN(7) = 0;
+
/* configure GPIO B2 (lcd D/C#) as output */
GPIOB_DIR |= (1<<2);
/* configure GPIO B3 (lcd type detect) as input */
GPIOB_DIR &= ~(1<<3);
-
+
/* configure GPIO A5 (lcd reset#) as output and perform lcd reset */
GPIOA_DIR |= (1 << 5);
GPIOA_PIN(5) = 0;
@@ -399,8 +407,8 @@ void lcd_update_rect(int x, int y, int width, int height)
ptr = &lcd_framebuffer[row][x];
for (col = x; col < x_end; col++) {
pixel = *ptr++;
- lcd_write_dat((pixel >> 8) & 0xFF);
lcd_write_dat((pixel >> 0) & 0xFF);
+ lcd_write_dat((pixel >> 8) & 0xFF);
}
}
}
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 7410b19..74925a3 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -376,11 +376,8 @@ static inline bool card_detect_target(void)
#if defined(HAVE_MULTIDRIVE)
#if defined(SANSA_FUZEV2)
return GPIOA_PIN(2);
-#elif defined(SANSA_CLIPPLUS)
+#elif defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
return !(GPIOA_PIN(2));
-#elif defined(SANSA_CLIPZIP)
- /* TODO for ClipZip: determine polarity of uSD detect */
- return false;
#else
#error "microSD pin not defined for your target"
#endif
@@ -398,14 +395,14 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
!send_cmd(drive, SD_APP_CMD, card_info[drive].rca, MCI_RESP, response))
return false;
-#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
if (amsv2_variant == 1)
GPIOB_PIN(5) = (drive == INTERNAL_AS3525) ? 1 << 5 : 0;
#endif
MCI_ARGUMENT = arg;
-#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
if (amsv2_variant == 1)
card_no = 1 << 16;
else
@@ -565,7 +562,7 @@ static int sd_init_card(const int drive)
return -17;
/* Now that card is widebus make controller aware */
-#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
if (amsv2_variant == 1)
MCI_CTYPE |= 1<<1;
else
@@ -575,7 +572,7 @@ static int sd_init_card(const int drive)
#endif /* ! BOOTLOADER */
/* Set low power mode */
-#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
if (amsv2_variant == 1)
MCI_CLKENA |= 1<<(1 + 16);
else
@@ -673,7 +670,7 @@ static void init_controller(void)
int card_mask = (1 << hcon_numcards) - 1;
int pwr_mask;
-#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
if (amsv2_variant == 1)
pwr_mask = 1 << 1;
else
@@ -738,7 +735,7 @@ int sd_init(void)
semaphore_init(&transfer_completion_signal, 1, 0);
semaphore_init(&command_completion_signal, 1, 0);
-#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
if (amsv2_variant == 1)
GPIOB_DIR |= 1 << 5;
#endif
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
index a79b934..2a40724 100644
--- a/firmware/target/arm/as3525/system-as3525.c
+++ b/firmware/target/arm/as3525/system-as3525.c
@@ -184,7 +184,7 @@ static void check_model_variant(void)
c200v2_variant = !GPIOA_PIN(7);
GPIOA_DIR = saved_dir;
}
-#elif defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#elif defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
int amsv2_variant;
static void check_model_variant(void)
diff --git a/firmware/target/arm/as3525/system-target.h b/firmware/target/arm/as3525/system-target.h
index 7c9dccc..cdcc2e6 100644
--- a/firmware/target/arm/as3525/system-target.h
+++ b/firmware/target/arm/as3525/system-target.h
@@ -46,7 +46,7 @@
? (((uintptr_t)(a)) - IRAM_ORIG) \
: ((uintptr_t)(a))))
-#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
+#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
extern int amsv2_variant;
#endif
diff --git a/rbutil/mkamsboot/dualboot.c b/rbutil/mkamsboot/dualboot.c
index b6ca1b3..b1bf69d 100644
--- a/rbutil/mkamsboot/dualboot.c
+++ b/rbutil/mkamsboot/dualboot.c
@@ -154,15 +154,16 @@ unsigned char dualboot_fuzev2[332] = {
0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8,
0x00, 0x00, 0x0d, 0xc8, 0x10, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x07, 0xc8
};
-unsigned char dualboot_clipzip[152] = {
+unsigned char dualboot_clipzip[168] = {
0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x48, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x02, 0x00, 0x00, 0xea, 0x4c, 0x00, 0x1f, 0xe5, 0x4c, 0x10, 0x1f, 0xe5,
- 0x01, 0x00, 0x00, 0xea, 0x60, 0x00, 0x1f, 0xe5, 0x60, 0x10, 0x1f, 0xe5, 0x58, 0x30, 0x1f, 0xe5,
- 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4,
- 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3,
- 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8
+ 0x2c, 0x30, 0x0f, 0xe5, 0x54, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
+ 0x00, 0x10, 0x80, 0xe5, 0x48, 0x00, 0x9f, 0xe5, 0x00, 0x11, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3,
+ 0x02, 0x00, 0x00, 0x1a, 0x58, 0x00, 0x1f, 0xe5, 0x58, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea,
+ 0x6c, 0x00, 0x1f, 0xe5, 0x6c, 0x10, 0x1f, 0xe5, 0x64, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2,
+ 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1,
+ 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1,
+ 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0b, 0xc8
};
diff --git a/rbutil/mkamsboot/dualboot.h b/rbutil/mkamsboot/dualboot.h
index 787aa09..a635753 100644
--- a/rbutil/mkamsboot/dualboot.h
+++ b/rbutil/mkamsboot/dualboot.h
@@ -9,4 +9,4 @@ extern unsigned char dualboot_fuze[176];
extern unsigned char dualboot_clipv2[248];
extern unsigned char dualboot_clipplus[340];
extern unsigned char dualboot_fuzev2[332];
-extern unsigned char dualboot_clipzip[152];
+extern unsigned char dualboot_clipzip[168];
diff --git a/rbutil/mkamsboot/dualboot/dualboot.S b/rbutil/mkamsboot/dualboot/dualboot.S
index 5d8fe12..b40ddab 100644
--- a/rbutil/mkamsboot/dualboot/dualboot.S
+++ b/rbutil/mkamsboot/dualboot/dualboot.S
@@ -175,8 +175,12 @@ uclcopy:
bne boot_of @ branch directly to OF if either pin high
#elif defined(SANSA_CLIPZIP)
- @ just boot the OF
- b boot_of
+ @ read pins
+ ldr r0, =GPIOA
+ ldr r1, [r0, #4*(1<<6)] @ read pin A6 "vol-" or "vol+"
+
+ cmp r1, #0 @ test input from pins
+ bne boot_of @ branch directly to OF if either pin high
#elif defined(SANSA_C200V2)
.set BUTTON_LEFT, (1<< 2)
diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c
index c50fe9f..073b32c 100644
--- a/rbutil/mkamsboot/mkamsboot.c
+++ b/rbutil/mkamsboot/mkamsboot.c
@@ -171,11 +171,11 @@ static struct md5sums sansasums[] = {
{ MODEL_FUZEV2, "2.02.26", "d4f6f85c3e4a8ea8f2e5acc421641801" },
{ MODEL_FUZEV2, "2.03.31", "74fb197ccd51707388f3b233402186a6" },
{ MODEL_FUZEV2, "2.03.33", "1599cc73d02ea7fe53fe2d4379c24b66" },
-#if 0 /* disabled for now because it's not been proven they can be patched */
+#if 1 /* disabled for now because it's not been proven they can be patched */
{ MODEL_CLIPZIP, "1.01.12", "45adea0873326b5af34f096e5c402f78" },
{ MODEL_CLIPZIP, "1.01.15", "f62af954334cd9ba1a87a7fa58ec6074" },
- { MODEL_CLIPZIP, "1.01.17", "27bcb343d6950f35dc261629e22ba60c" },
#endif
+ { MODEL_CLIPZIP, "1.01.17", "27bcb343d6950f35dc261629e22ba60c" },
};
#define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0]))
--
1.7.5.4