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 #include "config.h" 22 #include "system.h" 23 24 #include "gcc_extensions.h" 25 #include "storage.h" 26 #include "disk.h" ··· 208 root_menu(); 209 } 210 211 #ifdef HAVE_DIRCACHE 212 static int INIT_ATTR init_dircache(bool preinit) 213 { ··· 241 splash(0, str(LANG_SCANNING_DISK)); 242 dircache_wait(); 243 backlight_on(); 244 - show_logo(); 245 } 246 247 struct dircache_info info; ··· 307 if (clear) 308 { 309 backlight_on(); 310 - show_logo(); 311 } 312 } 313 #endif /* HAVE_TAGCACHE */ ··· 330 FOR_NB_SCREENS(i) 331 global_status.font_id[i] = FONT_SYSFIXED; 332 font_init(); 333 - show_logo(); 334 button_init(); 335 powermgmt_init(); 336 backlight_init(); ··· 434 settings_reset(); 435 436 CHART(">show_logo"); 437 - show_logo(); 438 CHART("<show_logo"); 439 lang_init(core_language_builtin, language_strings, 440 LANG_LAST_INDEX_IN_ARRAY);
··· 21 #include "config.h" 22 #include "system.h" 23 24 + #include "version.h" 25 #include "gcc_extensions.h" 26 #include "storage.h" 27 #include "disk.h" ··· 209 root_menu(); 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 + 256 #ifdef HAVE_DIRCACHE 257 static int INIT_ATTR init_dircache(bool preinit) 258 { ··· 286 splash(0, str(LANG_SCANNING_DISK)); 287 dircache_wait(); 288 backlight_on(); 289 + show_logo_boot(); 290 } 291 292 struct dircache_info info; ··· 352 if (clear) 353 { 354 backlight_on(); 355 + show_logo_boot(); 356 } 357 } 358 #endif /* HAVE_TAGCACHE */ ··· 375 FOR_NB_SCREENS(i) 376 global_status.font_id[i] = FONT_SYSFIXED; 377 font_init(); 378 + show_logo_boot(); 379 button_init(); 380 powermgmt_init(); 381 backlight_init(); ··· 479 settings_reset(); 480 481 CHART(">show_logo"); 482 + show_logo_boot(); 483 CHART("<show_logo"); 484 lang_init(core_language_builtin, language_strings, 485 LANG_LAST_INDEX_IN_ARRAY);
+3 -11
apps/menus/main_menu.c
··· 51 #include "disk.h" 52 53 static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG}; 54 - 55 /***********************************/ 56 /* MANAGE SETTINGS MENU */ 57 ··· 113 /***********************************/ 114 /* INFO MENU */ 115 116 - 117 static int show_credits(void) 118 { 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 - } 128 return 0; 129 } 130
··· 51 #include "disk.h" 52 53 static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG}; 54 + static int show_info(void); 55 /***********************************/ 56 /* MANAGE SETTINGS MENU */ 57 ··· 113 /***********************************/ 114 /* INFO MENU */ 115 116 static int show_credits(void) 117 { 118 + if (plugin_load(VIEWERS_DIR "/credits.rock", NULL) != PLUGIN_OK) 119 + show_info(); 120 return 0; 121 } 122
-54
apps/misc.c
··· 54 #include "power.h" 55 #include "powermgmt.h" 56 #include "backlight.h" 57 - #include "version.h" 58 #include "font.h" 59 #include "splash.h" 60 #include "tagcache.h" ··· 754 long default_event_handler(long event) 755 { 756 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 } 811 812 #ifdef BOOTFILE
··· 54 #include "power.h" 55 #include "powermgmt.h" 56 #include "backlight.h" 57 #include "font.h" 58 #include "splash.h" 59 #include "tagcache.h" ··· 753 long default_event_handler(long event) 754 { 755 return default_event_handler_ex(event, NULL, NULL); 756 } 757 758 #ifdef BOOTFILE
-1
apps/misc.h
··· 112 long default_event_handler(long event); 113 bool list_stop_handler(void); 114 void car_adapter_mode_init(void) INIT_ATTR; 115 - extern int show_logo(void); 116 117 /* Unicode byte order mark sequences and lengths */ 118 #define BOM_UTF_8 "\xef\xbb\xbf"
··· 112 long default_event_handler(long event); 113 bool list_stop_handler(void); 114 void car_adapter_mode_init(void) INIT_ATTR; 115 116 /* Unicode byte order mark sequences and lengths */ 117 #define BOM_UTF_8 "\xef\xbb\xbf"
-1
apps/plugin.c
··· 788 read_jpeg_fd, 789 #endif 790 screen_dump_set_hook, 791 - show_logo, 792 793 #ifdef HAVE_WHEEL_POSITION 794 wheel_status,
··· 788 read_jpeg_fd, 789 #endif 790 screen_dump_set_hook, 791 792 #ifdef HAVE_WHEEL_POSITION 793 wheel_status,
+2 -3
apps/plugin.h
··· 157 #define PLUGIN_MAGIC 0x526F634B /* RocK */ 158 159 /* increase this every time the api struct changes */ 160 - #define PLUGIN_API_VERSION 258 161 162 /* update this to latest version if a change to the api struct breaks 163 backwards compatibility (and please take the opportunity to sort in any 164 new function which are "waiting" at the end of the function table) */ 165 - #define PLUGIN_MIN_API_VERSION 258 166 167 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ 168 ··· 915 int format, const struct custom_format *cformat); 916 #endif 917 void (*screen_dump_set_hook)(void (*hook)(int fh)); 918 - int (*show_logo)(void); 919 920 #ifdef HAVE_WHEEL_POSITION 921 int (*wheel_status)(void);
··· 157 #define PLUGIN_MAGIC 0x526F634B /* RocK */ 158 159 /* increase this every time the api struct changes */ 160 + #define PLUGIN_API_VERSION 259 161 162 /* update this to latest version if a change to the api struct breaks 163 backwards compatibility (and please take the opportunity to sort in any 164 new function which are "waiting" at the end of the function table) */ 165 + #define PLUGIN_MIN_API_VERSION 259 166 167 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ 168 ··· 915 int format, const struct custom_format *cformat); 916 #endif 917 void (*screen_dump_set_hook)(void (*hook)(int fh)); 918 919 #ifdef HAVE_WHEEL_POSITION 920 int (*wheel_status)(void);
+71 -5
apps/plugins/credits.c
··· 21 #include "plugin.h" 22 #include "lib/helper.h" 23 24 25 26 static const char* const credits[] = { 27 #include "credits.raw" /* generated list of names from docs/CREDITS */ ··· 299 } 300 } 301 302 enum plugin_status plugin_start(const void* parameter) 303 { 304 (void)parameter; ··· 307 /* Turn off backlight timeout */ 308 backlight_ignore_timeout(); 309 310 - 311 - #if LCD_DEPTH>=16 312 rb->lcd_set_foreground (LCD_WHITE); 313 rb->lcd_set_background (LCD_BLACK); 314 #endif 315 - rb->show_logo(); 316 317 - /* Show the logo for about 3 secs allowing the user to stop */ 318 - if(!rb->action_userabort(3*HZ)) 319 roll_credits(); 320 321 322 /* Turn on backlight timeout (revert to settings) */ 323 backlight_use_settings();
··· 21 #include "plugin.h" 22 #include "lib/helper.h" 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 */ 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 37 38 static const char* const credits[] = { 39 #include "credits.raw" /* generated list of names from docs/CREDITS */ ··· 311 } 312 } 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 + 357 enum plugin_status plugin_start(const void* parameter) 358 { 359 (void)parameter; ··· 362 /* Turn off backlight timeout */ 363 backlight_ignore_timeout(); 364 365 + #if LCD_DEPTH > 1 366 rb->lcd_set_foreground (LCD_WHITE); 367 rb->lcd_set_background (LCD_BLACK); 368 #endif 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(); 376 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(); 381 roll_credits(); 382 + } 383 384 + #ifdef HAVE_REMOTE_LCD 385 + rb->lcd_remote_scroll_stop(); 386 + #endif 387 388 /* Turn on backlight timeout (revert to settings) */ 389 backlight_use_settings();
-7
apps/plugins/lua/rocklib.c
··· 930 return -1; 931 } 932 933 - RB_WRAP(show_logo) 934 - { 935 - rb->show_logo(); 936 - return 0; 937 - } 938 - 939 RB_WRAP(mem_stats) 940 { 941 /* used, allocd, free = rb.mem_stats() */ ··· 1032 1033 /* MISC */ 1034 RB_FUNC(restart_lua), 1035 - RB_FUNC(show_logo), 1036 RB_FUNC(mem_stats), 1037 1038 {NULL, NULL}
··· 930 return -1; 931 } 932 933 RB_WRAP(mem_stats) 934 { 935 /* used, allocd, free = rb.mem_stats() */ ··· 1026 1027 /* MISC */ 1028 RB_FUNC(restart_lua), 1029 RB_FUNC(mem_stats), 1030 1031 {NULL, NULL}
+13 -5
tools/bmp2rb.c
··· 512 if (!id || !id[0]) 513 id = "bitmap"; 514 515 f = stdout; 516 517 if (have_header) ··· 527 fprintf(fh, 528 "#define BMPHEIGHT_%s %d\n" 529 "#define BMPWIDTH_%s %d\n", 530 - id, height, id, width); 531 if (t_depth <= 8) 532 - fprintf(fh, "extern const unsigned char %s[];\n", id); 533 else if (t_depth <= 16) 534 - fprintf(fh, "extern const unsigned short %s[];\n", id); 535 else 536 - fprintf(fh, "extern const fb_data %s[];\n", id); 537 538 539 if (create_bm) 540 { 541 fprintf(f, "#include \"lcd.h\"\n"); 542 - fprintf(fh, "extern const struct bitmap bm_%s;\n", id); 543 } 544 fclose(fh); 545 } else {
··· 512 if (!id || !id[0]) 513 id = "bitmap"; 514 515 + bool initdata = create_bm && ((strcmp(id,"rockboxlogo") == 0) 516 + || (strcmp(id,"remote_rockboxlogo") == 0)); 517 + 518 f = stdout; 519 520 if (have_header) ··· 530 fprintf(fh, 531 "#define BMPHEIGHT_%s %d\n" 532 "#define BMPWIDTH_%s %d\n", 533 + id, height, id, width); 534 + 535 if (t_depth <= 8) 536 + fprintf(fh, "extern const unsigned char %s[]%s;\n", id, 537 + initdata ? " INITDATA_ATTR":""); 538 else if (t_depth <= 16) 539 + fprintf(fh, "extern const unsigned short %s[]%s;\n", id, 540 + initdata ? " INITDATA_ATTR":""); 541 else 542 + fprintf(fh, "extern const fb_data %s[]%s;\n", id, 543 + initdata ? " INITDATA_ATTR":""); 544 545 546 if (create_bm) 547 { 548 fprintf(f, "#include \"lcd.h\"\n"); 549 + fprintf(fh, "extern const struct bitmap bm_%s%s;\n", id, 550 + initdata ? " INITDATA_ATTR":""); 551 } 552 fclose(fh); 553 } else {