Make the updated %rg tag match playback behaviour (fall back to track gain if album...
[kugel-rb.git] / apps / misc.c
blob709bc492082c331fc7467c0394b1e6773eb94964
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Daniel Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include <stdlib.h>
20 #include <ctype.h>
21 #include "lang.h"
22 #include "string.h"
23 #include "config.h"
24 #include "file.h"
25 #include "dir.h"
26 #include "lcd.h"
27 #include "lcd-remote.h"
28 #include "sprintf.h"
29 #include "errno.h"
30 #include "system.h"
31 #include "timefuncs.h"
32 #include "screens.h"
33 #include "talk.h"
34 #include "mpeg.h"
35 #include "audio.h"
36 #include "mp3_playback.h"
37 #include "settings.h"
38 #include "ata.h"
39 #include "ata_idle_notify.h"
40 #include "kernel.h"
41 #include "power.h"
42 #include "powermgmt.h"
43 #include "backlight.h"
44 #include "atoi.h"
45 #include "version.h"
46 #include "font.h"
47 #include "splash.h"
48 #include "tagcache.h"
49 #include "scrobbler.h"
50 #ifdef HAVE_MMC
51 #include "ata_mmc.h"
52 #endif
53 #include "tree.h"
54 #include "eeprom_settings.h"
56 #ifdef HAVE_LCD_BITMAP
57 #include "bmp.h"
58 #include "icons.h"
59 #endif /* End HAVE_LCD_BITMAP */
60 #include "gui/gwps-common.h"
62 #include "misc.h"
64 /* Format a large-range value for output, using the appropriate unit so that
65 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
66 * units) if possible, and 3 significant digits are shown. If a buffer is
67 * given, the result is snprintf()'d into that buffer, otherwise the result is
68 * voiced.*/
69 char *output_dyn_value(char *buf, int buf_size, int value,
70 const unsigned char **units, bool bin_scale)
72 int scale = bin_scale ? 1024 : 1000;
73 int fraction = 0;
74 int unit_no = 0;
75 int i;
76 char tbuf[5];
78 while (value >= scale)
80 fraction = value % scale;
81 value /= scale;
82 unit_no++;
84 if (bin_scale)
85 fraction = fraction * 1000 / 1024;
87 if (value >= 100 || !unit_no)
88 tbuf[0] = '\0';
89 else if (value >= 10)
90 snprintf(tbuf, sizeof(tbuf), "%01d", fraction / 100);
91 else
92 snprintf(tbuf, sizeof(tbuf), "%02d", fraction / 10);
94 if (buf)
96 if (strlen(tbuf))
97 snprintf(buf, buf_size, "%d%s%s%s", value, str(LANG_POINT),
98 tbuf, P2STR(units[unit_no]));
99 else
100 snprintf(buf, buf_size, "%d%s", value, P2STR(units[unit_no]));
102 else
104 /* strip trailing zeros from the fraction */
105 for (i = strlen(tbuf) - 1; (i >= 0) && (tbuf[i] == '0'); i--)
106 tbuf[i] = '\0';
108 talk_number(value, true);
109 if (tbuf[0] != 0)
111 talk_id(LANG_POINT, true);
112 talk_spell(tbuf, true);
114 talk_id(P2ID(units[unit_no]), true);
116 return buf;
119 /* Create a filename with a number part in a way that the number is 1
120 * higher than the highest numbered file matching the same pattern.
121 * It is allowed that buffer and path point to the same memory location,
122 * saving a strcpy(). Path must always be given without trailing slash.
123 * "num" can point to an int specifying the number to use or NULL or a value
124 * less than zero to number automatically. The final number used will also
125 * be returned in *num. If *num is >= 0 then *num will be incremented by
126 * one. */
127 char *create_numbered_filename(char *buffer, const char *path,
128 const char *prefix, const char *suffix,
129 int numberlen IF_CNFN_NUM_(, int *num))
131 DIR *dir;
132 struct dirent *entry;
133 int max_num;
134 int pathlen;
135 int prefixlen = strlen(prefix);
136 char fmtstring[12];
138 if (buffer != path)
139 strncpy(buffer, path, MAX_PATH);
141 pathlen = strlen(buffer);
143 #ifdef IF_CNFN_NUM
144 if (num && *num >= 0)
146 /* number specified */
147 max_num = *num;
149 else
150 #endif
152 /* automatic numbering */
153 max_num = 0;
155 dir = opendir(pathlen ? buffer : "/");
156 if (!dir)
157 return NULL;
159 while ((entry = readdir(dir)))
161 int curr_num;
163 if (strncasecmp((char *)entry->d_name, prefix, prefixlen)
164 || strcasecmp((char *)entry->d_name + prefixlen + numberlen, suffix))
165 continue;
167 curr_num = atoi((char *)entry->d_name + prefixlen);
168 if (curr_num > max_num)
169 max_num = curr_num;
172 closedir(dir);
175 max_num++;
177 snprintf(fmtstring, sizeof(fmtstring), "/%%s%%0%dd%%s", numberlen);
178 snprintf(buffer + pathlen, MAX_PATH - pathlen, fmtstring, prefix,
179 max_num, suffix);
181 #ifdef IF_CNFN_NUM
182 if (num)
183 *num = max_num;
184 #endif
186 return buffer;
189 #ifdef CONFIG_RTC
190 /* Create a filename with a date+time part.
191 It is allowed that buffer and path point to the same memory location,
192 saving a strcpy(). Path must always be given without trailing slash.
193 unique_time as true makes the function wait until the current time has
194 changed. */
195 char *create_datetime_filename(char *buffer, const char *path,
196 const char *prefix, const char *suffix,
197 bool unique_time)
199 struct tm *tm = get_time();
200 static struct tm last_tm;
201 int pathlen;
203 while (unique_time && !memcmp(get_time(), &last_tm, sizeof (struct tm)))
204 sleep(HZ/10);
206 last_tm = *tm;
208 if (buffer != path)
209 strncpy(buffer, path, MAX_PATH);
211 pathlen = strlen(buffer);
212 snprintf(buffer + pathlen, MAX_PATH - pathlen,
213 "/%s%02d%02d%02d-%02d%02d%02d%s", prefix,
214 tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
215 tm->tm_hour, tm->tm_min, tm->tm_sec, suffix);
217 return buffer;
219 #endif /* CONFIG_RTC */
221 /* Read (up to) a line of text from fd into buffer and return number of bytes
222 * read (which may be larger than the number of bytes stored in buffer). If
223 * an error occurs, -1 is returned (and buffer contains whatever could be
224 * read). A line is terminated by a LF char. Neither LF nor CR chars are
225 * stored in buffer.
227 int read_line(int fd, char* buffer, int buffer_size)
229 int count = 0;
230 int num_read = 0;
232 errno = 0;
234 while (count < buffer_size)
236 unsigned char c;
238 if (1 != read(fd, &c, 1))
239 break;
241 num_read++;
243 if ( c == '\n' )
244 break;
246 if ( c == '\r' )
247 continue;
249 buffer[count++] = c;
252 buffer[MIN(count, buffer_size - 1)] = 0;
254 return errno ? -1 : num_read;
257 /* Performance optimized version of the previous function. */
258 int fast_readline(int fd, char *buf, int buf_size, void *parameters,
259 int (*callback)(int n, const char *buf, void *parameters))
261 char *p, *next;
262 int rc, pos = 0;
263 int count = 0;
265 while ( 1 )
267 next = NULL;
269 rc = read(fd, &buf[pos], buf_size - pos - 1);
270 if (rc >= 0)
271 buf[pos+rc] = '\0';
273 if ( (p = strchr(buf, '\r')) != NULL)
275 *p = '\0';
276 next = ++p;
278 else
279 p = buf;
281 if ( (p = strchr(p, '\n')) != NULL)
283 *p = '\0';
284 next = ++p;
287 rc = callback(count, buf, parameters);
288 if (rc < 0)
289 return rc;
291 count++;
292 if (next)
294 pos = buf_size - ((long)next - (long)buf) - 1;
295 memmove(buf, next, pos);
297 else
298 break ;
301 return 0;
304 #ifdef HAVE_LCD_BITMAP
306 #if LCD_DEPTH == 16
307 #define BMP_COMPRESSION 3 /* BI_BITFIELDS */
308 #define BMP_NUMCOLORS 3
309 #else
310 #define BMP_COMPRESSION 0 /* BI_RGB */
311 #if LCD_DEPTH <= 8
312 #define BMP_NUMCOLORS (1 << LCD_DEPTH)
313 #else
314 #define BMP_NUMCOLORS 0
315 #endif
316 #endif
318 #if LCD_DEPTH == 1
319 #define BMP_BPP 1
320 #define BMP_LINESIZE ((LCD_WIDTH/8 + 3) & ~3)
321 #elif LCD_DEPTH <= 4
322 #define BMP_BPP 4
323 #define BMP_LINESIZE ((LCD_WIDTH/2 + 3) & ~3)
324 #elif LCD_DEPTH <= 8
325 #define BMP_BPP 8
326 #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3)
327 #elif LCD_DEPTH <= 16
328 #define BMP_BPP 16
329 #define BMP_LINESIZE ((LCD_WIDTH*2 + 3) & ~3)
330 #else
331 #define BMP_BPP 24
332 #define BMP_LINESIZE ((LCD_WIDTH*3 + 3) & ~3)
333 #endif
335 #define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS)
336 #define BMP_DATASIZE (BMP_LINESIZE * LCD_HEIGHT)
337 #define BMP_TOTALSIZE (BMP_HEADERSIZE + BMP_DATASIZE)
339 #define LE16_CONST(x) (x)&0xff, ((x)>>8)&0xff
340 #define LE32_CONST(x) (x)&0xff, ((x)>>8)&0xff, ((x)>>16)&0xff, ((x)>>24)&0xff
342 static const unsigned char bmpheader[] =
344 0x42, 0x4d, /* 'BM' */
345 LE32_CONST(BMP_TOTALSIZE), /* Total file size */
346 0x00, 0x00, 0x00, 0x00, /* Reserved */
347 LE32_CONST(BMP_HEADERSIZE), /* Offset to start of pixel data */
349 0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */
350 LE32_CONST(LCD_WIDTH), /* Width in pixels */
351 LE32_CONST(LCD_HEIGHT), /* Height in pixels */
352 0x01, 0x00, /* Number of planes (always 1) */
353 LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */
354 LE32_CONST(BMP_COMPRESSION),/* Compression mode */
355 LE32_CONST(BMP_DATASIZE), /* Size of bitmap data */
356 0xc4, 0x0e, 0x00, 0x00, /* Horizontal resolution (pixels/meter) */
357 0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */
358 LE32_CONST(BMP_NUMCOLORS), /* Number of used colours */
359 LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */
361 #if LCD_DEPTH == 1
362 0x90, 0xee, 0x90, 0x00, /* Colour #0 */
363 0x00, 0x00, 0x00, 0x00 /* Colour #1 */
364 #elif LCD_DEPTH == 2
365 0xe6, 0xd8, 0xad, 0x00, /* Colour #0 */
366 0x99, 0x90, 0x73, 0x00, /* Colour #1 */
367 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */
368 0x00, 0x00, 0x00, 0x00 /* Colour #3 */
369 #elif LCD_DEPTH == 16
370 0x00, 0xf8, 0x00, 0x00, /* red bitfield mask */
371 0xe0, 0x07, 0x00, 0x00, /* green bitfield mask */
372 0x1f, 0x00, 0x00, 0x00 /* blue bitfield mask */
373 #endif
376 static void (*screen_dump_hook)(int fh) = NULL;
378 void screen_dump(void)
380 int fh;
381 char filename[MAX_PATH];
382 int bx, by;
383 #if LCD_DEPTH == 1
384 static unsigned char line_block[8][BMP_LINESIZE];
385 #elif LCD_DEPTH == 2
386 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
387 static unsigned char line_block[BMP_LINESIZE];
388 #else
389 static unsigned char line_block[4][BMP_LINESIZE];
390 #endif
391 #elif LCD_DEPTH == 16
392 static unsigned short line_block[BMP_LINESIZE/2];
393 #endif
395 #ifdef CONFIG_RTC
396 create_datetime_filename(filename, "", "dump ", ".bmp", false);
397 #else
398 create_numbered_filename(filename, "", "dump_", ".bmp", 4
399 IF_CNFN_NUM_(, NULL));
400 #endif
402 fh = creat(filename, O_WRONLY);
403 if (fh < 0)
404 return;
406 if (screen_dump_hook)
408 screen_dump_hook(fh);
410 else
412 write(fh, bmpheader, sizeof(bmpheader));
414 /* BMP image goes bottom up */
415 #if LCD_DEPTH == 1
416 for (by = LCD_HEIGHT/8 - 1; by >= 0; by--)
418 unsigned char *src = &lcd_framebuffer[by][0];
419 unsigned char *dst = &line_block[0][0];
421 memset(line_block, 0, sizeof(line_block));
422 for (bx = LCD_WIDTH/8; bx > 0; bx--)
424 unsigned dst_mask = 0x80;
425 int ix;
427 for (ix = 8; ix > 0; ix--)
429 unsigned char *dst_blk = dst;
430 unsigned src_byte = *src++;
431 int iy;
433 for (iy = 8; iy > 0; iy--)
435 if (src_byte & 0x80)
436 *dst_blk |= dst_mask;
437 src_byte <<= 1;
438 dst_blk += BMP_LINESIZE;
440 dst_mask >>= 1;
442 dst++;
445 write(fh, line_block, sizeof(line_block));
447 #elif LCD_DEPTH == 2
448 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
449 for (by = LCD_HEIGHT - 1; by >= 0; by--)
451 unsigned char *src = &lcd_framebuffer[by][0];
452 unsigned char *dst = line_block;
454 memset(line_block, 0, sizeof(line_block));
455 for (bx = (LCD_WIDTH+3)/4; bx > 0; bx--)
457 unsigned src_byte = *src++;
459 *dst++ = ((src_byte >> 2) & 0x30) | ((src_byte >> 4) & 0x03);
460 *dst++ = ((src_byte << 2) & 0x30) | (src_byte & 0x03);
463 write(fh, line_block, sizeof(line_block));
465 #else /* VERTICAL_PACKING */
466 for (by = LCD_HEIGHT/4 - 1; by >= 0; by--)
468 unsigned char *src = &lcd_framebuffer[by][0];
469 unsigned char *dst = &line_block[3][0];
471 memset(line_block, 0, sizeof(line_block));
472 for (bx = LCD_WIDTH/2; bx > 0; bx--)
474 unsigned char *dst_blk = dst++;
475 unsigned src_byte0 = *src++;
476 unsigned src_byte1 = *src++;
477 int iy;
479 for (iy = 4; iy > 0; iy--)
481 *dst_blk = ((src_byte0 & 3) << 4) | (src_byte1 & 3);
482 src_byte0 >>= 2;
483 src_byte1 >>= 2;
484 dst_blk -= BMP_LINESIZE;
488 write(fh, line_block, sizeof(line_block));
490 #endif
491 #elif LCD_DEPTH == 16
492 for (by = LCD_HEIGHT - 1; by >= 0; by--)
494 unsigned short *src = &lcd_framebuffer[by][0];
495 unsigned short *dst = line_block;
497 memset(line_block, 0, sizeof(line_block));
498 for (bx = LCD_WIDTH; bx > 0; bx--)
500 #if (LCD_PIXELFORMAT == RGB565SWAPPED)
501 /* iPod LCD data is big endian although the CPU is not */
502 *dst++ = htobe16(*src++);
503 #else
504 *dst++ = htole16(*src++);
505 #endif
508 write(fh, line_block, sizeof(line_block));
510 #endif /* LCD_DEPTH */
513 close(fh);
516 void screen_dump_set_hook(void (*hook)(int fh))
518 screen_dump_hook = hook;
521 #endif /* HAVE_LCD_BITMAP */
523 /* parse a line from a configuration file. the line format is:
525 name: value
527 Any whitespace before setting name or value (after ':') is ignored.
528 A # as first non-whitespace character discards the whole line.
529 Function sets pointers to null-terminated setting name and value.
530 Returns false if no valid config entry was found.
533 bool settings_parseline(char* line, char** name, char** value)
535 char* ptr;
537 while ( isspace(*line) )
538 line++;
540 if ( *line == '#' )
541 return false;
543 ptr = strchr(line, ':');
544 if ( !ptr )
545 return false;
547 *name = line;
548 *ptr = 0;
549 ptr++;
550 while (isspace(*ptr))
551 ptr++;
552 *value = ptr;
553 return true;
556 static void system_flush(void)
558 call_ata_idle_notifys(false); /*doesnt work on usb and shutdown from ata thread */
559 tree_flush();
562 static void system_restore(void)
564 tree_restore();
567 static bool clean_shutdown(void (*callback)(void *), void *parameter)
569 #ifdef SIMULATOR
570 (void)callback;
571 (void)parameter;
572 call_ata_idle_notifys(false);
573 exit(0);
574 #else
575 int i;
577 #if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
578 if(!charger_inserted())
579 #endif
581 FOR_NB_SCREENS(i)
582 screens[i].clear_display();
583 #ifdef X5_BACKLIGHT_SHUTDOWN
584 x5_backlight_shutdown();
585 #endif
586 if (!battery_level_safe())
587 gui_syncsplash(3*HZ, true, "%s %s",
588 str(LANG_WARNING_BATTERY_EMPTY),
589 str(LANG_SHUTTINGDOWN));
590 else if (battery_level_critical())
591 gui_syncsplash(3*HZ, true, "%s %s",
592 str(LANG_WARNING_BATTERY_LOW),
593 str(LANG_SHUTTINGDOWN));
594 else {
595 #ifdef HAVE_TAGCACHE
596 if (!tagcache_prepare_shutdown())
598 cancel_shutdown();
599 gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
600 return false;
602 #endif
603 gui_syncsplash(0, true, str(LANG_SHUTTINGDOWN));
606 if (global_settings.fade_on_stop
607 && (audio_status() & AUDIO_STATUS_PLAY))
609 fade(0);
612 audio_stop();
613 while (audio_status())
614 sleep(1);
616 if (callback != NULL)
617 callback(parameter);
619 if (!battery_level_critical()) /* do not save on critical battery */
620 system_flush();
621 #ifdef HAVE_EEPROM_SETTINGS
622 if (firmware_settings.initialized)
624 firmware_settings.disk_clean = true;
625 firmware_settings.bl_version = 0;
626 eeprom_settings_store();
628 #endif
629 shutdown_hw();
631 #endif
632 return false;
635 #ifdef CONFIG_CHARGING
636 static bool waiting_to_resume_play = false;
637 static long play_resume_tick;
639 static void car_adapter_mode_processing(bool inserted)
641 if (global_settings.car_adapter_mode)
643 if(inserted)
646 * Just got plugged in, delay & resume if we were playing
648 if (audio_status() & AUDIO_STATUS_PAUSE)
650 /* delay resume a bit while the engine is cranking */
651 play_resume_tick = current_tick + HZ*5;
652 waiting_to_resume_play = true;
655 else
658 * Just got unplugged, pause if playing
660 if ((audio_status() & AUDIO_STATUS_PLAY) &&
661 !(audio_status() & AUDIO_STATUS_PAUSE))
663 audio_pause();
669 static void car_adapter_tick(void)
671 if (waiting_to_resume_play)
673 if (TIME_AFTER(current_tick, play_resume_tick))
675 if (audio_status() & AUDIO_STATUS_PAUSE)
677 audio_resume();
679 waiting_to_resume_play = false;
684 void car_adapter_mode_init(void)
686 tick_add_task(car_adapter_tick);
688 #endif
690 #ifdef HAVE_HEADPHONE_DETECTION
691 void unplug_change(bool inserted)
693 if (global_settings.unplug_mode)
695 if (inserted)
697 if ( global_settings.unplug_mode > 1 )
698 audio_resume();
699 backlight_on();
700 } else {
701 audio_pause();
703 if (global_settings.unplug_rw)
705 if ( audio_current_track()->elapsed >
706 (unsigned long)(global_settings.unplug_rw*1000))
707 audio_ff_rewind(audio_current_track()->elapsed -
708 (global_settings.unplug_rw*1000));
709 else
710 audio_ff_rewind(0);
715 #endif
717 long default_event_handler_ex(long event, void (*callback)(void *), void *parameter)
719 switch(event)
721 case SYS_USB_CONNECTED:
722 if (callback != NULL)
723 callback(parameter);
724 #ifdef HAVE_MMC
725 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
726 #endif
728 scrobbler_flush_cache();
729 system_flush();
730 usb_screen();
731 system_restore();
733 return SYS_USB_CONNECTED;
734 case SYS_POWEROFF:
735 if (!clean_shutdown(callback, parameter))
736 return SYS_POWEROFF;
737 break;
738 #ifdef CONFIG_CHARGING
739 case SYS_CHARGER_CONNECTED:
740 car_adapter_mode_processing(true);
741 return SYS_CHARGER_CONNECTED;
743 case SYS_CHARGER_DISCONNECTED:
744 car_adapter_mode_processing(false);
745 return SYS_CHARGER_DISCONNECTED;
746 #endif
747 #ifdef HAVE_HEADPHONE_DETECTION
748 case SYS_PHONE_PLUGGED:
749 unplug_change(true);
750 return SYS_PHONE_PLUGGED;
752 case SYS_PHONE_UNPLUGGED:
753 unplug_change(false);
754 return SYS_PHONE_UNPLUGGED;
755 #endif
757 return 0;
760 long default_event_handler(long event)
762 return default_event_handler_ex(event, NULL, NULL);
765 int show_logo( void )
767 #ifdef HAVE_LCD_BITMAP
768 char version[32];
769 int font_h, font_w;
771 lcd_clear_display();
772 lcd_bitmap(rockboxlogo, 0, 10, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
774 #ifdef HAVE_REMOTE_LCD
775 lcd_remote_clear_display();
776 lcd_remote_bitmap(remote_rockboxlogo, 0, 10, BMPWIDTH_remote_rockboxlogo,
777 BMPHEIGHT_remote_rockboxlogo);
778 #endif
780 snprintf(version, sizeof(version), "Ver. %s", appsversion);
781 lcd_setfont(FONT_SYSFIXED);
782 lcd_getstringsize((unsigned char *)"A", &font_w, &font_h);
783 lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2),
784 LCD_HEIGHT-font_h, (unsigned char *)version);
785 lcd_update();
787 #ifdef HAVE_REMOTE_LCD
788 lcd_remote_setfont(FONT_SYSFIXED);
789 lcd_remote_getstringsize((unsigned char *)"A", &font_w, &font_h);
790 lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - ((strlen(version)*font_w)/2),
791 LCD_REMOTE_HEIGHT-font_h, (unsigned char *)version);
792 lcd_remote_update();
793 #endif
795 #else
796 char *rockbox = " ROCKbox!";
797 lcd_clear_display();
798 lcd_double_height(true);
799 lcd_puts(0, 0, rockbox);
800 lcd_puts(0, 1, appsversion);
801 #endif
803 return 0;
806 #if CONFIG_CODEC == SWCODEC
807 int get_replaygain_mode(bool have_track_gain, bool have_album_gain)
809 int type;
811 bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK)
812 || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
813 && global_settings.playlist_shuffle));
815 type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM
816 : have_track_gain ? REPLAYGAIN_TRACK : -1;
818 return type;
820 #endif