summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Artiukhin <bahusdrive@gmail.com>2024-02-19 13:59:51 +0200
committerAidan MacDonald <amachronic@protonmail.com>2024-04-01 11:02:04 -0400
commitc36d7768c539921754dd26ded343a08e11ccc0f0 (patch)
tree2001649699a6d646f6d2fc4ec5400841ee293277
parent2570909e52b4121d69b0bc6638af8882dae87176 (diff)
downloadrockbox-c36d7768c539921754dd26ded343a08e11ccc0f0.tar.gz
rockbox-c36d7768c539921754dd26ded343a08e11ccc0f0.zip
Sansa e200v2: bootloader: fit size
Max allowed size: 120860 Old thumb build: 128494 New thumb build: 118514 (fits!) Disabled: Logo; alpha blending capabilities for bitmaps; Arm stack unwinder (backtrace); Related forum discussion: https://forums.rockbox.org/index.php/topic,54768.0.html Fixes FS#12380 Change-Id: I978720d795cb0ef5169103e467cf8386c21d8e93
-rw-r--r--bootloader/show_logo.c5
-rw-r--r--firmware/drivers/lcd-16bit-common.c3
-rw-r--r--firmware/drivers/lcd-16bit-vert.c2
-rw-r--r--firmware/drivers/lcd-16bit.c3
-rw-r--r--firmware/drivers/lcd-24bit.c4
-rw-r--r--firmware/drivers/lcd-bitmap-common.c2
-rw-r--r--firmware/drivers/lcd-color-common.c4
-rw-r--r--firmware/export/config/sansae200v2.h7
-rw-r--r--firmware/export/lcd.h2
-rw-r--r--firmware/export/system.h2
-rw-r--r--firmware/panic.c2
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c12
-rw-r--r--firmware/target/arm/system-arm.c4
13 files changed, 41 insertions, 11 deletions
diff --git a/bootloader/show_logo.c b/bootloader/show_logo.c
index 6584e3f24d..cafcb45dcf 100644
--- a/bootloader/show_logo.c
+++ b/bootloader/show_logo.c
@@ -25,8 +25,9 @@
25#include <string.h> 25#include <string.h>
26#include "version.h" 26#include "version.h"
27 27
28#ifndef DISABLE_LOGO
28#include "bitmaps/rockboxlogo.h" 29#include "bitmaps/rockboxlogo.h"
29 30#endif
30#if LCD_WIDTH <= 128 31#if LCD_WIDTH <= 128
31#define BOOT_VERFMT "Boot %s" 32#define BOOT_VERFMT "Boot %s"
32#else 33#else
@@ -54,7 +55,9 @@ void show_logo( void )
54 lcd_putsxy(text_xpos, 0, verstr); 55 lcd_putsxy(text_xpos, 0, verstr);
55 lcd_bmp(&bm_rockboxlogo, LOGO_XPOS, 16); 56 lcd_bmp(&bm_rockboxlogo, LOGO_XPOS, 16);
56#else 57#else
58#ifndef DISABLE_LOGO
57 lcd_bmp(&bm_rockboxlogo, LOGO_XPOS, 10); 59 lcd_bmp(&bm_rockboxlogo, LOGO_XPOS, 10);
60#endif
58 lcd_putsxy(text_xpos, LCD_HEIGHT-SYSFONT_HEIGHT, verstr); 61 lcd_putsxy(text_xpos, LCD_HEIGHT-SYSFONT_HEIGHT, verstr);
59#endif 62#endif
60 63
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index 9d24dfe16e..ab136bf238 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -335,7 +335,7 @@ void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int heig
335 lcd_mono_bitmap_part(src, 0, 0, width, x, y, width, height); 335 lcd_mono_bitmap_part(src, 0, 0, width, x, y, width, height);
336} 336}
337 337
338 338#ifndef DISABLE_ALPHA_BITMAP
339/* About Rockbox' internal alpha channel format (for ALPHA_BPP == 4) 339/* About Rockbox' internal alpha channel format (for ALPHA_BPP == 4)
340 * 340 *
341 * For each pixel, 4bit of alpha information is stored in a byte-stream, 341 * For each pixel, 4bit of alpha information is stored in a byte-stream,
@@ -654,3 +654,4 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(
654 654
655 BLEND_FINISH; 655 BLEND_FINISH;
656} 656}
657#endif /* !DISABLE_ALPHA_BITMAP */ \ No newline at end of file
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c
index d4ad218d14..6532ea5121 100644
--- a/firmware/drivers/lcd-16bit-vert.c
+++ b/firmware/drivers/lcd-16bit-vert.c
@@ -47,11 +47,13 @@
47extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[]; 47extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[];
48extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[]; 48extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[];
49 49
50#ifndef DISABLE_ALPHA_BITMAP
50static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, 51static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
51 const unsigned char *src, int src_x, 52 const unsigned char *src, int src_x,
52 int src_y, int x, int y, 53 int src_y, int x, int y,
53 int width, int height, 54 int width, int height,
54 int stride_image, int stride_src); 55 int stride_image, int stride_src);
56#endif /* !DISABLE_ALPHA_BITMAP */
55 57
56#include "lcd-color-common.c" 58#include "lcd-color-common.c"
57#include "lcd-bitmap-common.c" 59#include "lcd-bitmap-common.c"
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index fbf6700f28..967878b2e4 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -47,12 +47,13 @@
47extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[]; 47extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[];
48extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[]; 48extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[];
49 49
50#ifndef DISABLE_ALPHA_BITMAP
50static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, 51static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
51 const unsigned char *src, int src_x, 52 const unsigned char *src, int src_x,
52 int src_y, int x, int y, 53 int src_y, int x, int y,
53 int width, int height, 54 int width, int height,
54 int stride_image, int stride_src); 55 int stride_image, int stride_src);
55 56#endif /* !DISABLE_ALPHA_BITMAP */
56#include "lcd-color-common.c" 57#include "lcd-color-common.c"
57#include "lcd-bitmap-common.c" 58#include "lcd-bitmap-common.c"
58#include "lcd-16bit-common.c" 59#include "lcd-16bit-common.c"
diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c
index dbb7e543af..64ddf4a201 100644
--- a/firmware/drivers/lcd-24bit.c
+++ b/firmware/drivers/lcd-24bit.c
@@ -47,13 +47,13 @@
47 47
48extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[]; 48extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[];
49extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[]; 49extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[];
50 50#ifndef DISABLE_ALPHA_BITMAP
51static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, 51static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
52 const unsigned char *src, int src_x, 52 const unsigned char *src, int src_x,
53 int src_y, int x, int y, 53 int src_y, int x, int y,
54 int width, int height, 54 int width, int height,
55 int stride_image, int stride_src); 55 int stride_image, int stride_src);
56 56#endif /* !DISABLE_ALPHA_BITMAP */
57#include "lcd-color-common.c" 57#include "lcd-color-common.c"
58#include "lcd-bitmap-common.c" 58#include "lcd-bitmap-common.c"
59 59
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 975c494b5a..75d31e3453 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -563,7 +563,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
563 563
564 bits = font_get_bits(pf, *ucs); 564 bits = font_get_bits(pf, *ucs);
565 565
566#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) 566#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) && !defined(DISABLE_ALPHA_BITMAP)
567 if (pf->depth) 567 if (pf->depth)
568 lcd_alpha_bitmap_part(bits, ofs, 0, width, x, y, 568 lcd_alpha_bitmap_part(bits, ofs, 0, width, x, y,
569 width - ofs, pf->height); 569 width - ofs, pf->height);
diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c
index 5f83160dab..1ec965d816 100644
--- a/firmware/drivers/lcd-color-common.c
+++ b/firmware/drivers/lcd-color-common.c
@@ -166,6 +166,7 @@ void lcd_bitmap_transparent(const fb_data *src, int x, int y,
166 STRIDE(SCREEN_MAIN, width, height), x, y, width, height); 166 STRIDE(SCREEN_MAIN, width, height), x, y, width, height);
167} 167}
168 168
169#ifndef DISABLE_ALPHA_BITMAP
169/* draw alpha bitmap for anti-alias font */ 170/* draw alpha bitmap for anti-alias font */
170void ICODE_ATTR lcd_alpha_bitmap_part(const unsigned char *src, int src_x, 171void ICODE_ATTR lcd_alpha_bitmap_part(const unsigned char *src, int src_x,
171 int src_y, int stride, int x, int y, 172 int src_y, int stride, int x, int y,
@@ -173,6 +174,7 @@ void ICODE_ATTR lcd_alpha_bitmap_part(const unsigned char *src, int src_x,
173{ 174{
174 lcd_alpha_bitmap_part_mix(NULL, src, src_x, src_y, x, y, width, height, 0, stride); 175 lcd_alpha_bitmap_part_mix(NULL, src, src_x, src_y, x, y, width, height, 0, stride);
175} 176}
177#endif /* !DISABLE_ALPHA_BITMAP */
176 178
177/* Draw a partial bitmap (mono or native) including alpha channel */ 179/* Draw a partial bitmap (mono or native) including alpha channel */
178void ICODE_ATTR lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y, 180void ICODE_ATTR lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y,
@@ -181,10 +183,12 @@ void ICODE_ATTR lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y,
181 int bitmap_stride = LCD_FBSTRIDE(bm->width, bm->height); 183 int bitmap_stride = LCD_FBSTRIDE(bm->width, bm->height);
182 if (bm->format == FORMAT_MONO) 184 if (bm->format == FORMAT_MONO)
183 lcd_mono_bitmap_part(bm->data, src_x, src_y, bm->width, x, y, width, height); 185 lcd_mono_bitmap_part(bm->data, src_x, src_y, bm->width, x, y, width, height);
186#ifndef DISABLE_ALPHA_BITMAP
184 else if (bm->alpha_offset > 0) 187 else if (bm->alpha_offset > 0)
185 lcd_alpha_bitmap_part_mix((fb_data*)bm->data, bm->data+bm->alpha_offset, 188 lcd_alpha_bitmap_part_mix((fb_data*)bm->data, bm->data+bm->alpha_offset,
186 src_x, src_y, x, y, width, height, 189 src_x, src_y, x, y, width, height,
187 bitmap_stride, ALIGN_UP(bm->width, 2)); 190 bitmap_stride, ALIGN_UP(bm->width, 2));
191#endif /* !DISABLE_ALPHA_BITMAP */
188 else 192 else
189 lcd_bitmap_transparent_part((fb_data*)bm->data, 193 lcd_bitmap_transparent_part((fb_data*)bm->data,
190 src_x, src_y, bitmap_stride, x, y, width, height); 194 src_x, src_y, bitmap_stride, x, y, width, height);
diff --git a/firmware/export/config/sansae200v2.h b/firmware/export/config/sansae200v2.h
index 00833d56a6..e7ff291cc7 100644
--- a/firmware/export/config/sansae200v2.h
+++ b/firmware/export/config/sansae200v2.h
@@ -65,14 +65,17 @@
65#define HAVE_LCD_SLEEP 65#define HAVE_LCD_SLEEP
66#define HAVE_LCD_SLEEP_SETTING 66#define HAVE_LCD_SLEEP_SETTING
67 */ 67 */
68#endif
69 68
70/* define this if you can flip your LCD */ 69/* define this if you can flip your LCD */
71#define HAVE_LCD_FLIP 70#define HAVE_LCD_FLIP
72 71
73/* define this if you can invert the colours on your LCD */ 72/* define this if you can invert the colours on your LCD */
74#define HAVE_LCD_INVERT 73#define HAVE_LCD_INVERT
75 74#else /* !BOOTLOADER */
75#define DISABLE_ALPHA_BITMAP
76#define DISABLE_LOGO
77#define DISABLE_BACKTRACE
78#endif /* !BOOTLOADER */
76/* put the lcd frame buffer in IRAM */ 79/* put the lcd frame buffer in IRAM */
77#define IRAM_LCDFRAMEBUFFER IBSS_ATTR 80#define IRAM_LCDFRAMEBUFFER IBSS_ATTR
78 81
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 67b22190ad..05d12cc2ec 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -237,7 +237,7 @@ extern bool lcd_putsxy_scroll_func(int x, int y, const unsigned char *string,
237 237
238/* performance function */ 238/* performance function */
239#if defined(HAVE_LCD_COLOR) 239#if defined(HAVE_LCD_COLOR)
240#if MEMORYSIZE > 2 240#if MEMORYSIZE > 2 && !defined(BOOTLOADER)
241#define LCD_YUV_DITHER 0x1 241#define LCD_YUV_DITHER 0x1
242 extern void lcd_yuv_set_options(unsigned options); 242 extern void lcd_yuv_set_options(unsigned options);
243 extern void lcd_blit_yuv(unsigned char * const src[3], 243 extern void lcd_blit_yuv(unsigned char * const src[3],
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 172fe05b6e..552540a1db 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -266,8 +266,10 @@ static inline void cpu_boost_unlock(void)
266/* Define this if target has support for generating backtraces */ 266/* Define this if target has support for generating backtraces */
267#if defined(CPU_ARM) || \ 267#if defined(CPU_ARM) || \
268 (defined(CPU_MIPS) && (CONFIG_PLATFORM & PLATFORM_NATIVE)) 268 (defined(CPU_MIPS) && (CONFIG_PLATFORM & PLATFORM_NATIVE))
269#ifndef DISABLE_BACKTRACE
269 #define HAVE_RB_BACKTRACE 270 #define HAVE_RB_BACKTRACE
270#endif 271#endif
272#endif
271 273
272#ifndef MIN_STACK_ALIGN 274#ifndef MIN_STACK_ALIGN
273#define MIN_STACK_ALIGN (sizeof (uintptr_t)) 275#define MIN_STACK_ALIGN (sizeof (uintptr_t))
diff --git a/firmware/panic.c b/firmware/panic.c
index d7f330caf1..bbe241a26d 100644
--- a/firmware/panic.c
+++ b/firmware/panic.c
@@ -46,7 +46,7 @@ static char panic_buf[128];
46 46
47#define LINECHARS (LCD_WIDTH/SYSFONT_WIDTH) - 2 47#define LINECHARS (LCD_WIDTH/SYSFONT_WIDTH) - 2
48 48
49#if defined(CPU_ARM) 49#if defined(CPU_ARM) && defined(HAVE_RB_BACKTRACE)
50void panicf_f( const char *fmt, ...); 50void panicf_f( const char *fmt, ...);
51 51
52/* we wrap panicf() here with naked function to catch SP value */ 52/* we wrap panicf() here with naked function to catch SP value */
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
index f69ad48793..1344ea6fa8 100644
--- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
+++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
@@ -149,6 +149,7 @@ static void lcd_write_reg(int reg, int value)
149 149
150void lcd_set_invert_display(bool yesno) 150void lcd_set_invert_display(bool yesno)
151{ 151{
152#ifdef HAVE_LCD_INVERT
152 r_disp_control_rev = yesno ? R_DISP_CONTROL_REV : 153 r_disp_control_rev = yesno ? R_DISP_CONTROL_REV :
153 R_DISP_CONTROL_NORMAL; 154 R_DISP_CONTROL_NORMAL;
154 155
@@ -156,9 +157,13 @@ void lcd_set_invert_display(bool yesno)
156 { 157 {
157 lcd_write_reg(R_DISP_CONTROL1, 0x0033 | r_disp_control_rev); 158 lcd_write_reg(R_DISP_CONTROL1, 0x0033 | r_disp_control_rev);
158 } 159 }
160#else
161 (void)yesno;
162#endif
159 163
160} 164}
161 165
166#ifdef HAVE_LCD_FLIP
162static bool display_flipped = false; 167static bool display_flipped = false;
163 168
164/* turn the display upside down */ 169/* turn the display upside down */
@@ -169,15 +174,19 @@ void lcd_set_flip(bool yesno)
169 r_entry_mode = yesno ? R_ENTRY_MODE_HORZ_FLIPPED : 174 r_entry_mode = yesno ? R_ENTRY_MODE_HORZ_FLIPPED :
170 R_ENTRY_MODE_HORZ_NORMAL; 175 R_ENTRY_MODE_HORZ_NORMAL;
171} 176}
177#endif // HAVE_LCD_FLIP
172 178
173static void lcd_window(int xmin, int ymin, int xmax, int ymax) 179static void lcd_window(int xmin, int ymin, int xmax, int ymax)
174{ 180{
181#ifdef HAVE_LCD_FLIP
175 if (!display_flipped) 182 if (!display_flipped)
183#endif
176 { 184 {
177 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin); 185 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin);
178 lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin); 186 lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
179 lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | xmin); 187 lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | xmin);
180 } 188 }
189#ifdef HAVE_LCD_FLIP
181 else 190 else
182 { 191 {
183 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 192 lcd_write_reg(R_HORIZ_RAM_ADDR_POS,
@@ -187,6 +196,7 @@ static void lcd_window(int xmin, int ymin, int xmax, int ymax)
187 lcd_write_reg(R_RAM_ADDR_SET, 196 lcd_write_reg(R_RAM_ADDR_SET,
188 ((LCD_HEIGHT-1 - ymin) << 8) | (LCD_WIDTH-1 - xmin)); 197 ((LCD_HEIGHT-1 - ymin) << 8) | (LCD_WIDTH-1 - xmin));
189 } 198 }
199#endif // HAVE_LCD_FLIP
190} 200}
191 201
192static void _display_on(void) 202static void _display_on(void)
@@ -431,7 +441,7 @@ void lcd_blit_yuv(unsigned char * const src[3],
431 } 441 }
432} 442}
433 443
434#endif 444#endif /* !BOOTLOADER */
435 445
436 446
437/* Update the display. 447/* Update the display.
diff --git a/firmware/target/arm/system-arm.c b/firmware/target/arm/system-arm.c
index 74df5ed277..41d0cce723 100644
--- a/firmware/target/arm/system-arm.c
+++ b/firmware/target/arm/system-arm.c
@@ -145,11 +145,15 @@ void NORETURN_ATTR UIE(unsigned int pc, unsigned int num)
145 } /* num == 1 || num == 2 // prefetch/data abort */ 145 } /* num == 1 || num == 2 // prefetch/data abort */
146#endif /* !defined(CPU_ARM7TDMI */ 146#endif /* !defined(CPU_ARM7TDMI */
147 147
148#ifdef HAVE_RB_BACKTRACE
148 if (!triggered) 149 if (!triggered)
149 { 150 {
150 triggered = true; 151 triggered = true;
151 rb_backtrace(pc, __get_sp(), &line); 152 rb_backtrace(pc, __get_sp(), &line);
152 } 153 }
154#else
155 (void)triggered;
156#endif
153 157
154 lcd_update(); 158 lcd_update();
155 159