Advertisement
Guest User

Rockbox port for Clip Zip, work-in-progress

a guest
Oct 28th, 2011
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 13.70 KB | None | 0 0
  1. From 204c9b06d310fc2c4f2cf0fe0f595f60afbf7747 Mon Sep 17 00:00:00 2001
  2. From: Bertrik Sikken <bertrik@sikken.nl>
  3. Date: Sat, 29 Oct 2011 00:01:04 +0200
  4. Subject: [PATCH] Clip zip port WIP
  5.  
  6. ---
  7. firmware/export/config/sansaclipzip.h              |    8 +++++---
  8.  .../arm/as3525/sansa-clipzip/backlight-clipzip.c   |   18 ++++++++----------
  9.  .../arm/as3525/sansa-clipzip/button-clipzip.c      |   10 +++++-----
  10.  .../target/arm/as3525/sansa-clipzip/lcd-clipzip.c  |   12 ++++++++++--
  11.  firmware/target/arm/as3525/sd-as3525v2.c           |   17 +++++++----------
  12.  firmware/target/arm/as3525/system-as3525.c         |    2 +-
  13.  firmware/target/arm/as3525/system-target.h         |    2 +-
  14.  rbutil/mkamsboot/dualboot.c                        |   15 ++++++++-------
  15.  rbutil/mkamsboot/dualboot.h                        |    2 +-
  16.  rbutil/mkamsboot/dualboot/dualboot.S               |    8 ++++++--
  17.  rbutil/mkamsboot/mkamsboot.c                       |    4 ++--
  18.  11 files changed, 54 insertions(+), 44 deletions(-)
  19.  
  20. diff --git a/firmware/export/config/sansaclipzip.h b/firmware/export/config/sansaclipzip.h
  21. index fcffbce..c40dc4b 100644
  22. --- a/firmware/export/config/sansaclipzip.h
  23. +++ b/firmware/export/config/sansaclipzip.h
  24. @@ -45,7 +45,7 @@
  25.  #define LCD_WIDTH  96
  26.  #define LCD_HEIGHT 96
  27.  #define LCD_DEPTH  16   /* 65536 colours */
  28. -#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 swapped */
  29. +#define LCD_PIXELFORMAT RGB565
  30.  
  31.  /* define this if you have LCD enable function */
  32.  #define HAVE_LCD_ENABLE
  33. @@ -114,6 +114,8 @@
  34.  /* Define this for LCD backlight available */
  35.  #define HAVE_BACKLIGHT
  36.  
  37. +#define HAVE_BACKLIGHT_BRIGHTNESS
  38. +
  39.  /* define this if you have a flash memory storage */
  40.  #define HAVE_FLASH_STORAGE
  41.  
  42. @@ -189,8 +191,8 @@
  43.  /** Port-specific settings **/
  44.  
  45.  /* Main LCD backlight brightness range and defaults */
  46. -#define MIN_BRIGHTNESS_SETTING      1   /* TODO */
  47. -#define MAX_BRIGHTNESS_SETTING     12   /* TODO */
  48. +#define MIN_BRIGHTNESS_SETTING      0   /* TODO */
  49. +#define MAX_BRIGHTNESS_SETTING     10   /* TODO */
  50.  #define DEFAULT_BRIGHTNESS_SETTING  6   /* TODO */
  51.  
  52.  /* Default recording levels */
  53. diff --git a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
  54. index 758aa87..589f804 100644
  55. --- a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
  56. +++ b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
  57. @@ -25,11 +25,14 @@
  58.  #include "lcd.h"
  59.  #include "as3525v2.h"
  60.  #include "ascodec-target.h"
  61. +#include "lcd-target.h"
  62.  
  63.  bool _backlight_init()
  64.  {
  65.      /* GPIO B1 controls backlight */
  66.      GPIOB_DIR |= (1 << 1);
  67. +    ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
  68. +    GPIOB_PIN(1) = (1 << 1);
  69.      
  70.      return true;
  71.  }
  72. @@ -37,13 +40,6 @@ bool _backlight_init()
  73.  void _backlight_on(void)
  74.  {
  75.      GPIOB_PIN(1) = (1 << 1);
  76. -    
  77. -    ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
  78. -    sleep(1);
  79. -    ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
  80. -    sleep(1);
  81. -    ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
  82. -
  83.  #ifdef HAVE_LCD_ENABLE
  84.      lcd_enable(true);
  85.  #endif
  86. @@ -54,9 +50,11 @@ void _backlight_off(void)
  87.  #ifdef HAVE_LCD_ENABLE
  88.      lcd_enable(false);
  89.  #endif
  90. -
  91.      GPIOB_PIN(1) = 0;
  92. -    
  93. -    ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
  94. +}
  95. +
  96. +void _backlight_set_brightness(int brightness)
  97. +{
  98. +    oled_brightness(brightness);
  99.  }
  100.  
  101. diff --git a/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c
  102. index 104c227..e960b49 100644
  103. --- a/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c
  104. +++ b/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c
  105. @@ -71,13 +71,13 @@ int button_read_device(void)
  106.      udelay(500);
  107.      
  108.      if (GPIOC_PIN(3)) {
  109. -        buttons |= BUTTON_LEFT;
  110. +        buttons |= BUTTON_RIGHT;
  111.      }
  112.      if (GPIOC_PIN(4)) {
  113.          buttons |= BUTTON_SELECT;
  114.      }
  115.      if (GPIOC_PIN(5)) {
  116. -        buttons |= BUTTON_RIGHT;
  117. +        buttons |= BUTTON_UP;
  118.      }
  119.      
  120.      /* key matrix buttons, second row */
  121. @@ -86,13 +86,13 @@ int button_read_device(void)
  122.      udelay(500);
  123.      
  124.      if (GPIOC_PIN(3)) {
  125. -        buttons |= BUTTON_UP;
  126. +        buttons |= BUTTON_HOME;
  127.      }
  128.      if (GPIOC_PIN(4)) {
  129. -        buttons |= BUTTON_HOME;
  130. +        buttons |= BUTTON_DOWN;
  131.      }
  132.      if (GPIOC_PIN(5)) {
  133. -        buttons |= BUTTON_DOWN;
  134. +        buttons |= BUTTON_LEFT;
  135.      }
  136.      
  137.      /* deselect scan rows */
  138. diff --git a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
  139. index 899eb53..929961d 100644
  140. --- a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
  141. +++ b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
  142. @@ -51,12 +51,20 @@ static int lcd_hw_init(void)
  143.      SSP_IMSC &= ~0xF;       /* disable interrupts */
  144.      SSP_DMACR &= ~0x3;      /* disable DMA */
  145.  
  146. +    // ??
  147. +    GPIOA_DIR |= (1 << 3);
  148. +    GPIOA_PIN(3) = (1 << 3);
  149. +    GPIOA_DIR |= (1 << 0);
  150. +    GPIOA_PIN(0) = (1 << 0);
  151. +    GPIOB_DIR |= (1 << 7);
  152. +    GPIOB_PIN(7) = 0;
  153. +
  154.      /* configure GPIO B2 (lcd D/C#) as output */
  155.      GPIOB_DIR |= (1<<2);
  156.  
  157.      /* configure GPIO B3 (lcd type detect) as input */
  158.      GPIOB_DIR &= ~(1<<3);
  159. -
  160. +    
  161.      /* configure GPIO A5 (lcd reset#) as output and perform lcd reset */
  162.      GPIOA_DIR |= (1 << 5);
  163.      GPIOA_PIN(5) = 0;
  164. @@ -399,8 +407,8 @@ void lcd_update_rect(int x, int y, int width, int height)
  165.          ptr = &lcd_framebuffer[row][x];
  166.          for (col = x; col < x_end; col++) {
  167.              pixel = *ptr++;
  168. -            lcd_write_dat((pixel >> 8) & 0xFF);
  169.              lcd_write_dat((pixel >> 0) & 0xFF);
  170. +            lcd_write_dat((pixel >> 8) & 0xFF);
  171.          }
  172.      }
  173.  }
  174. diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
  175. index 7410b19..74925a3 100644
  176. --- a/firmware/target/arm/as3525/sd-as3525v2.c
  177. +++ b/firmware/target/arm/as3525/sd-as3525v2.c
  178. @@ -376,11 +376,8 @@ static inline bool card_detect_target(void)
  179.  #if defined(HAVE_MULTIDRIVE)
  180.  #if defined(SANSA_FUZEV2)
  181.      return GPIOA_PIN(2);
  182. -#elif defined(SANSA_CLIPPLUS)
  183. +#elif defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  184.      return !(GPIOA_PIN(2));
  185. -#elif defined(SANSA_CLIPZIP)
  186. -    /* TODO for ClipZip: determine polarity of uSD detect */
  187. -    return false;
  188.  #else
  189.  #error "microSD pin not defined for your target"
  190.  #endif
  191. @@ -398,14 +395,14 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
  192.          !send_cmd(drive, SD_APP_CMD, card_info[drive].rca, MCI_RESP, response))
  193.          return false;
  194.  
  195. -#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  196. +#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  197.      if (amsv2_variant == 1)
  198.          GPIOB_PIN(5) = (drive == INTERNAL_AS3525) ? 1 << 5 : 0;
  199.  #endif
  200.  
  201.      MCI_ARGUMENT = arg;
  202.  
  203. -#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  204. +#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  205.      if (amsv2_variant == 1)
  206.          card_no = 1 << 16;
  207.      else
  208. @@ -565,7 +562,7 @@ static int sd_init_card(const int drive)
  209.          return -17;
  210.  
  211.      /* Now that card is widebus make controller aware */
  212. -#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  213. +#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  214.      if (amsv2_variant == 1)
  215.          MCI_CTYPE |= 1<<1;
  216.      else
  217. @@ -575,7 +572,7 @@ static int sd_init_card(const int drive)
  218.  #endif /* ! BOOTLOADER */
  219.  
  220.      /*  Set low power mode  */
  221. -#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  222. +#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  223.      if (amsv2_variant == 1)
  224.          MCI_CLKENA |= 1<<(1 + 16);
  225.      else
  226. @@ -673,7 +670,7 @@ static void init_controller(void)
  227.      int card_mask = (1 << hcon_numcards) - 1;
  228.      int pwr_mask;
  229.  
  230. -#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  231. +#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  232.      if (amsv2_variant == 1)
  233.          pwr_mask = 1 << 1;
  234.      else
  235. @@ -738,7 +735,7 @@ int sd_init(void)
  236.      semaphore_init(&transfer_completion_signal, 1, 0);
  237.      semaphore_init(&command_completion_signal, 1, 0);
  238.  
  239. -#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  240. +#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  241.      if (amsv2_variant == 1)
  242.          GPIOB_DIR |= 1 << 5;
  243.  #endif
  244. diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
  245. index a79b934..2a40724 100644
  246. --- a/firmware/target/arm/as3525/system-as3525.c
  247. +++ b/firmware/target/arm/as3525/system-as3525.c
  248. @@ -184,7 +184,7 @@ static void check_model_variant(void)
  249.      c200v2_variant = !GPIOA_PIN(7);
  250.      GPIOA_DIR = saved_dir;
  251.  }
  252. -#elif defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  253. +#elif defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  254.  int amsv2_variant;
  255.  
  256.  static void check_model_variant(void)
  257. diff --git a/firmware/target/arm/as3525/system-target.h b/firmware/target/arm/as3525/system-target.h
  258. index 7c9dccc..cdcc2e6 100644
  259. --- a/firmware/target/arm/as3525/system-target.h
  260. +++ b/firmware/target/arm/as3525/system-target.h
  261. @@ -46,7 +46,7 @@
  262.          ? (((uintptr_t)(a)) - IRAM_ORIG) \
  263.          : ((uintptr_t)(a))))
  264.  
  265. -#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS)
  266. +#if defined(SANSA_FUZEV2) || defined(SANSA_CLIPPLUS) || defined(SANSA_CLIPZIP)
  267.  extern int amsv2_variant;
  268.  #endif
  269.  
  270. diff --git a/rbutil/mkamsboot/dualboot.c b/rbutil/mkamsboot/dualboot.c
  271. index b6ca1b3..b1bf69d 100644
  272. --- a/rbutil/mkamsboot/dualboot.c
  273. +++ b/rbutil/mkamsboot/dualboot.c
  274. @@ -154,15 +154,16 @@ unsigned char dualboot_fuzev2[332] = {
  275.      0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8,
  276.      0x00, 0x00, 0x0d, 0xc8, 0x10, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x07, 0xc8
  277.  };
  278. -unsigned char dualboot_clipzip[152] = {
  279. +unsigned char dualboot_clipzip[168] = {
  280.      0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  281.      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  282.      0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
  283.      0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
  284. -    0x2c, 0x30, 0x0f, 0xe5, 0x48, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
  285. -    0x00, 0x10, 0x80, 0xe5, 0x02, 0x00, 0x00, 0xea, 0x4c, 0x00, 0x1f, 0xe5, 0x4c, 0x10, 0x1f, 0xe5,
  286. -    0x01, 0x00, 0x00, 0xea, 0x60, 0x00, 0x1f, 0xe5, 0x60, 0x10, 0x1f, 0xe5, 0x58, 0x30, 0x1f, 0xe5,
  287. -    0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4,
  288. -    0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3,
  289. -    0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8
  290. +    0x2c, 0x30, 0x0f, 0xe5, 0x54, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
  291. +    0x00, 0x10, 0x80, 0xe5, 0x48, 0x00, 0x9f, 0xe5, 0x00, 0x11, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3,
  292. +    0x02, 0x00, 0x00, 0x1a, 0x58, 0x00, 0x1f, 0xe5, 0x58, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea,
  293. +    0x6c, 0x00, 0x1f, 0xe5, 0x6c, 0x10, 0x1f, 0xe5, 0x64, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2,
  294. +    0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1,
  295. +    0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1,
  296. +    0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0b, 0xc8
  297.  };
  298. diff --git a/rbutil/mkamsboot/dualboot.h b/rbutil/mkamsboot/dualboot.h
  299. index 787aa09..a635753 100644
  300. --- a/rbutil/mkamsboot/dualboot.h
  301. +++ b/rbutil/mkamsboot/dualboot.h
  302. @@ -9,4 +9,4 @@ extern unsigned char dualboot_fuze[176];
  303.  extern unsigned char dualboot_clipv2[248];
  304.  extern unsigned char dualboot_clipplus[340];
  305.  extern unsigned char dualboot_fuzev2[332];
  306. -extern unsigned char dualboot_clipzip[152];
  307. +extern unsigned char dualboot_clipzip[168];
  308. diff --git a/rbutil/mkamsboot/dualboot/dualboot.S b/rbutil/mkamsboot/dualboot/dualboot.S
  309. index 5d8fe12..b40ddab 100644
  310. --- a/rbutil/mkamsboot/dualboot/dualboot.S
  311. +++ b/rbutil/mkamsboot/dualboot/dualboot.S
  312. @@ -175,8 +175,12 @@ uclcopy:
  313.          bne     boot_of             @ branch directly to OF if either pin high
  314.  
  315.  #elif defined(SANSA_CLIPZIP)
  316. -        @ just boot the OF
  317. -        b       boot_of
  318. +        @ read pins
  319. +        ldr     r0, =GPIOA
  320. +        ldr     r1, [r0, #4*(1<<6)] @ read pin A6 "vol-" or "vol+"
  321. +
  322. +        cmp     r1, #0              @ test input from pins
  323. +        bne     boot_of             @ branch directly to OF if either pin high
  324.  
  325.  #elif defined(SANSA_C200V2)
  326.  .set BUTTON_LEFT,      (1<< 2)
  327. diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c
  328. index c50fe9f..073b32c 100644
  329. --- a/rbutil/mkamsboot/mkamsboot.c
  330. +++ b/rbutil/mkamsboot/mkamsboot.c
  331. @@ -171,11 +171,11 @@ static struct md5sums sansasums[] = {
  332.      { MODEL_FUZEV2, "2.02.26", "d4f6f85c3e4a8ea8f2e5acc421641801" },
  333.      { MODEL_FUZEV2, "2.03.31", "74fb197ccd51707388f3b233402186a6" },
  334.      { MODEL_FUZEV2, "2.03.33", "1599cc73d02ea7fe53fe2d4379c24b66" },
  335. -#if 0 /* disabled for now because it's not been proven they can be patched */
  336. +#if 1 /* disabled for now because it's not been proven they can be patched */
  337.      { MODEL_CLIPZIP, "1.01.12", "45adea0873326b5af34f096e5c402f78" },
  338.      { MODEL_CLIPZIP, "1.01.15", "f62af954334cd9ba1a87a7fa58ec6074" },
  339. -    { MODEL_CLIPZIP, "1.01.17", "27bcb343d6950f35dc261629e22ba60c" },
  340.  #endif
  341. +    { MODEL_CLIPZIP, "1.01.17", "27bcb343d6950f35dc261629e22ba60c" },
  342.  };
  343.  
  344.  #define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0]))
  345. --
  346. 1.7.5.4
  347.  
  348.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement