A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

remove rockboxlogo after boot INIT_ATTR

nets about 5k on clipzip (less on mono, more on others)
to move rockboxlogo to .initdata section

Remove show_logo completely and move to main.c
remove plugin stub
give credits plugin its own copy
credit fallback is now show_info()

Change-Id: Id9ed787e605ed29e7ab1e7a74d3821cd0f840ed4

authored by

William Wilgus and committed by
William Wilgus
1930ca8d f37ebe5e

+138 -91
+49 -4
apps/main.c
··· 21 21 #include "config.h" 22 22 #include "system.h" 23 23 24 + #include "version.h" 24 25 #include "gcc_extensions.h" 25 26 #include "storage.h" 26 27 #include "disk.h" ··· 208 209 root_menu(); 209 210 } 210 211 212 + /* The disk isn't ready at boot, rblogo is stored in bin and erased after boot */ 213 + int show_logo_boot( void ) INIT_ATTR; 214 + int show_logo_boot( void ) 215 + { 216 + unsigned char version[32]; 217 + int font_h, ver_w; 218 + snprintf(version, sizeof(version), "Ver. %s", rbversion); 219 + ver_w = font_getstringsize(version, NULL, &font_h, FONT_SYSFIXED); 220 + lcd_clear_display(); 221 + lcd_setfont(FONT_SYSFIXED); 222 + #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS) 223 + /* display the logo in the blue area of the screen (bottom 48 pixels) */ 224 + if (ver_w > LCD_WIDTH) 225 + lcd_putsxy(0, 0, rbversion); 226 + else 227 + lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), 0, version); 228 + lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16); 229 + #else 230 + lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10); 231 + if (ver_w > LCD_WIDTH) 232 + lcd_putsxy(0, LCD_HEIGHT-font_h, rbversion); 233 + else 234 + lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), LCD_HEIGHT-font_h, version); 235 + #endif 236 + lcd_setfont(FONT_UI); 237 + lcd_update(); 238 + #ifdef HAVE_REMOTE_LCD 239 + lcd_remote_clear_display(); 240 + lcd_remote_bmp(&bm_remote_rockboxlogo, 0, 10); 241 + lcd_remote_setfont(FONT_SYSFIXED); 242 + if (ver_w > LCD_REMOTE_WIDTH) 243 + lcd_remote_putsxy(0, LCD_REMOTE_HEIGHT-font_h, rbversion); 244 + else 245 + lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - (ver_w/2), 246 + LCD_REMOTE_HEIGHT-font_h, version); 247 + lcd_remote_setfont(FONT_UI); 248 + lcd_remote_update(); 249 + #endif 250 + #ifdef SIMULATOR 251 + sleep(HZ); /* sim is too fast to see logo */ 252 + #endif 253 + return 0; 254 + } 255 + 211 256 #ifdef HAVE_DIRCACHE 212 257 static int INIT_ATTR init_dircache(bool preinit) 213 258 { ··· 241 286 splash(0, str(LANG_SCANNING_DISK)); 242 287 dircache_wait(); 243 288 backlight_on(); 244 - show_logo(); 289 + show_logo_boot(); 245 290 } 246 291 247 292 struct dircache_info info; ··· 307 352 if (clear) 308 353 { 309 354 backlight_on(); 310 - show_logo(); 355 + show_logo_boot(); 311 356 } 312 357 } 313 358 #endif /* HAVE_TAGCACHE */ ··· 330 375 FOR_NB_SCREENS(i) 331 376 global_status.font_id[i] = FONT_SYSFIXED; 332 377 font_init(); 333 - show_logo(); 378 + show_logo_boot(); 334 379 button_init(); 335 380 powermgmt_init(); 336 381 backlight_init(); ··· 434 479 settings_reset(); 435 480 436 481 CHART(">show_logo"); 437 - show_logo(); 482 + show_logo_boot(); 438 483 CHART("<show_logo"); 439 484 lang_init(core_language_builtin, language_strings, 440 485 LANG_LAST_INDEX_IN_ARRAY);
+3 -11
apps/menus/main_menu.c
··· 51 51 #include "disk.h" 52 52 53 53 static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG}; 54 - 54 + static int show_info(void); 55 55 /***********************************/ 56 56 /* MANAGE SETTINGS MENU */ 57 57 ··· 113 113 /***********************************/ 114 114 /* INFO MENU */ 115 115 116 - 117 116 static int show_credits(void) 118 117 { 119 - char credits[MAX_PATH] = { '\0' }; 120 - snprintf(credits, MAX_PATH, "%s/credits.rock", VIEWERS_DIR); 121 - if (plugin_load(credits, NULL) != PLUGIN_OK) 122 - { 123 - /* show the rockbox logo and version untill a button is pressed */ 124 - show_logo(); 125 - while (IS_SYSEVENT(get_action(CONTEXT_STD, TIMEOUT_BLOCK))) 126 - ; 127 - } 118 + if (plugin_load(VIEWERS_DIR "/credits.rock", NULL) != PLUGIN_OK) 119 + show_info(); 128 120 return 0; 129 121 } 130 122
-54
apps/misc.c
··· 54 54 #include "power.h" 55 55 #include "powermgmt.h" 56 56 #include "backlight.h" 57 - #include "version.h" 58 57 #include "font.h" 59 58 #include "splash.h" 60 59 #include "tagcache.h" ··· 754 753 long default_event_handler(long event) 755 754 { 756 755 return default_event_handler_ex(event, NULL, NULL); 757 - } 758 - 759 - int show_logo( void ) 760 - { 761 - unsigned char version[32]; 762 - int font_h, ver_w; 763 - 764 - snprintf(version, sizeof(version), "Ver. %s", rbversion); 765 - 766 - ver_w = font_getstringsize(version, NULL, &font_h, FONT_SYSFIXED); 767 - 768 - lcd_clear_display(); 769 - 770 - lcd_setfont(FONT_SYSFIXED); 771 - 772 - #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS) 773 - /* display the logo in the blue area of the screen (bottom 48 pixels) */ 774 - if (ver_w > LCD_WIDTH) 775 - lcd_putsxy(0, 0, rbversion); 776 - else 777 - lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), 0, version); 778 - 779 - lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16); 780 - #else 781 - lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10); 782 - 783 - if (ver_w > LCD_WIDTH) 784 - lcd_putsxy(0, LCD_HEIGHT-font_h, rbversion); 785 - else 786 - lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), LCD_HEIGHT-font_h, version); 787 - #endif 788 - lcd_setfont(FONT_UI); 789 - 790 - lcd_update(); 791 - 792 - #ifdef HAVE_REMOTE_LCD 793 - lcd_remote_clear_display(); 794 - lcd_remote_bmp(&bm_remote_rockboxlogo, 0, 10); 795 - lcd_remote_setfont(FONT_SYSFIXED); 796 - 797 - if (ver_w > LCD_REMOTE_WIDTH) 798 - lcd_remote_putsxy(0, LCD_REMOTE_HEIGHT-font_h, rbversion); 799 - else 800 - lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - (ver_w/2), 801 - LCD_REMOTE_HEIGHT-font_h, version); 802 - 803 - lcd_remote_setfont(FONT_UI); 804 - lcd_remote_update(); 805 - #endif 806 - #ifdef SIMULATOR 807 - sleep(HZ); /* sim is too fast to see logo */ 808 - #endif 809 - return 0; 810 756 } 811 757 812 758 #ifdef BOOTFILE
-1
apps/misc.h
··· 112 112 long default_event_handler(long event); 113 113 bool list_stop_handler(void); 114 114 void car_adapter_mode_init(void) INIT_ATTR; 115 - extern int show_logo(void); 116 115 117 116 /* Unicode byte order mark sequences and lengths */ 118 117 #define BOM_UTF_8 "\xef\xbb\xbf"
-1
apps/plugin.c
··· 788 788 read_jpeg_fd, 789 789 #endif 790 790 screen_dump_set_hook, 791 - show_logo, 792 791 793 792 #ifdef HAVE_WHEEL_POSITION 794 793 wheel_status,
+2 -3
apps/plugin.h
··· 157 157 #define PLUGIN_MAGIC 0x526F634B /* RocK */ 158 158 159 159 /* increase this every time the api struct changes */ 160 - #define PLUGIN_API_VERSION 258 160 + #define PLUGIN_API_VERSION 259 161 161 162 162 /* update this to latest version if a change to the api struct breaks 163 163 backwards compatibility (and please take the opportunity to sort in any 164 164 new function which are "waiting" at the end of the function table) */ 165 - #define PLUGIN_MIN_API_VERSION 258 165 + #define PLUGIN_MIN_API_VERSION 259 166 166 167 167 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ 168 168 ··· 915 915 int format, const struct custom_format *cformat); 916 916 #endif 917 917 void (*screen_dump_set_hook)(void (*hook)(int fh)); 918 - int (*show_logo)(void); 919 918 920 919 #ifdef HAVE_WHEEL_POSITION 921 920 int (*wheel_status)(void);
+71 -5
apps/plugins/credits.c
··· 21 21 #include "plugin.h" 22 22 #include "lib/helper.h" 23 23 24 + #ifdef HAVE_REMOTE_LCD 25 + #define REMOTE_WIDTH LCD_REMOTE_WIDTH 26 + #define REMOTE_HEIGHT LCD_REMOTE_HEIGHT 27 + #include "pluginbitmaps/remote_rockboxlogo.h" 28 + #define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo 29 + #define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo 30 + #define REMOTE_LOGO (const fb_remote_data*)remote_rockboxlogo 31 + #endif /* HAVE_REMOTE_LCD */ 24 32 33 + #define LOGO (const fb_data*)rockboxlogo 34 + #include "pluginbitmaps/rockboxlogo.h" 35 + #define LOGO_WIDTH BMPWIDTH_rockboxlogo 36 + #define LOGO_HEIGHT BMPHEIGHT_rockboxlogo 25 37 26 38 static const char* const credits[] = { 27 39 #include "credits.raw" /* generated list of names from docs/CREDITS */ ··· 299 311 } 300 312 } 301 313 314 + int show_logo(void) 315 + { 316 + unsigned char version[32]; 317 + int font_h, ver_w; 318 + rb->snprintf(version, sizeof(version), "Ver. %s", rb->rbversion); 319 + ver_w = rb->font_getstringsize(version, NULL, &font_h, FONT_SYSFIXED); 320 + rb->lcd_clear_display(); 321 + rb->lcd_setfont(FONT_SYSFIXED); 322 + #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS) 323 + /* display the logo in the blue area of the screen (bottom 48 pixels) */ 324 + if (ver_w > LCD_WIDTH) 325 + rb->lcd_puts_scroll(0, 0, version); 326 + else 327 + rb->lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), 0, version); 328 + rb->lcd_bitmap(LOGO, (LCD_WIDTH - LOGO_WIDTH) / 2, 16, 329 + LOGO_WIDTH, LOGO_HEIGHT); 330 + #else 331 + rb->lcd_bitmap(LOGO, (LCD_WIDTH - LOGO_WIDTH) / 2, 10, 332 + LOGO_WIDTH, LOGO_HEIGHT); 333 + if (ver_w > LCD_WIDTH) 334 + rb->lcd_puts_scroll(0, (LCD_HEIGHT-font_h) / font_h, version); 335 + else 336 + rb->lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), LCD_HEIGHT-font_h, version); 337 + #endif 338 + rb->lcd_setfont(FONT_UI); 339 + rb->lcd_update(); 340 + #ifdef HAVE_REMOTE_LCD 341 + rb->lcd_remote_clear_display(); 342 + rb->lcd_remote_bitmap(REMOTE_LOGO, 0, 10, 343 + REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT); 344 + rb->lcd_remote_setfont(FONT_SYSFIXED); 345 + if (ver_w > LCD_REMOTE_WIDTH) 346 + rb->lcd_remote_puts_scroll(0, (LCD_REMOTE_HEIGHT-font_h) / font_h, version); 347 + else 348 + rb->lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - (ver_w/2), 349 + LCD_REMOTE_HEIGHT-font_h, version); 350 + rb->lcd_remote_setfont(FONT_UI); 351 + rb->lcd_remote_update(); 352 + #endif 353 + 354 + return 0; 355 + } 356 + 302 357 enum plugin_status plugin_start(const void* parameter) 303 358 { 304 359 (void)parameter; ··· 307 362 /* Turn off backlight timeout */ 308 363 backlight_ignore_timeout(); 309 364 310 - 311 - #if LCD_DEPTH>=16 365 + #if LCD_DEPTH > 1 312 366 rb->lcd_set_foreground (LCD_WHITE); 313 367 rb->lcd_set_background (LCD_BLACK); 314 368 #endif 315 - rb->show_logo(); 369 + #ifdef HAVE_REMOTE_LCD 370 + #if (LCD_REMOTE_DEPTH > 1) 371 + rb->lcd_remote_set_foreground (LCD_WHITE); 372 + rb->lcd_remote_set_background (LCD_BLACK); 373 + #endif 374 + #endif 375 + show_logo(); 316 376 317 - /* Show the logo for about 3 secs allowing the user to stop */ 318 - if(!rb->action_userabort(3*HZ)) 377 + /* Show the logo for about 5 secs allowing the user to stop */ 378 + if(!rb->action_userabort(5*HZ)) 379 + { 380 + rb->lcd_scroll_stop(); 319 381 roll_credits(); 382 + } 320 383 384 + #ifdef HAVE_REMOTE_LCD 385 + rb->lcd_remote_scroll_stop(); 386 + #endif 321 387 322 388 /* Turn on backlight timeout (revert to settings) */ 323 389 backlight_use_settings();
-7
apps/plugins/lua/rocklib.c
··· 930 930 return -1; 931 931 } 932 932 933 - RB_WRAP(show_logo) 934 - { 935 - rb->show_logo(); 936 - return 0; 937 - } 938 - 939 933 RB_WRAP(mem_stats) 940 934 { 941 935 /* used, allocd, free = rb.mem_stats() */ ··· 1032 1026 1033 1027 /* MISC */ 1034 1028 RB_FUNC(restart_lua), 1035 - RB_FUNC(show_logo), 1036 1029 RB_FUNC(mem_stats), 1037 1030 1038 1031 {NULL, NULL}
+13 -5
tools/bmp2rb.c
··· 512 512 if (!id || !id[0]) 513 513 id = "bitmap"; 514 514 515 + bool initdata = create_bm && ((strcmp(id,"rockboxlogo") == 0) 516 + || (strcmp(id,"remote_rockboxlogo") == 0)); 517 + 515 518 f = stdout; 516 519 517 520 if (have_header) ··· 527 530 fprintf(fh, 528 531 "#define BMPHEIGHT_%s %d\n" 529 532 "#define BMPWIDTH_%s %d\n", 530 - id, height, id, width); 533 + id, height, id, width); 534 + 531 535 if (t_depth <= 8) 532 - fprintf(fh, "extern const unsigned char %s[];\n", id); 536 + fprintf(fh, "extern const unsigned char %s[]%s;\n", id, 537 + initdata ? " INITDATA_ATTR":""); 533 538 else if (t_depth <= 16) 534 - fprintf(fh, "extern const unsigned short %s[];\n", id); 539 + fprintf(fh, "extern const unsigned short %s[]%s;\n", id, 540 + initdata ? " INITDATA_ATTR":""); 535 541 else 536 - fprintf(fh, "extern const fb_data %s[];\n", id); 542 + fprintf(fh, "extern const fb_data %s[]%s;\n", id, 543 + initdata ? " INITDATA_ATTR":""); 537 544 538 545 539 546 if (create_bm) 540 547 { 541 548 fprintf(f, "#include \"lcd.h\"\n"); 542 - fprintf(fh, "extern const struct bitmap bm_%s;\n", id); 549 + fprintf(fh, "extern const struct bitmap bm_%s%s;\n", id, 550 + initdata ? " INITDATA_ATTR":""); 543 551 } 544 552 fclose(fh); 545 553 } else {