summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/settings.c257
-rw-r--r--docs/CUSTOM_EQ_FORMAT40
-rw-r--r--firmware/mpeg.c45
-rw-r--r--firmware/mpeg.h1
-rw-r--r--uisimulator/win32/Makefile5
-rw-r--r--uisimulator/x11/Makefile5
6 files changed, 186 insertions, 167 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 450a85b2da..98258f5d8d 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -39,6 +39,8 @@
39#include "status.h" 39#include "status.h"
40#include "atoi.h" 40#include "atoi.h"
41#include "screens.h" 41#include "screens.h"
42#include "ctype.h"
43#include "file.h"
42#ifdef HAVE_LCD_BITMAP 44#ifdef HAVE_LCD_BITMAP
43#include "icons.h" 45#include "icons.h"
44#include "font.h" 46#include "font.h"
@@ -459,161 +461,120 @@ void settings_load(void)
459#endif 461#endif
460} 462}
461 463
462/* 464static int read_line(int fd, char* buffer, int buffer_size)
463 * Loads a .eq file 465{
464 */ 466 int count = 0;
467
468 while (count < buffer_size)
469 {
470 unsigned char c;
471
472 if (1 != read(fd, &c, 1))
473 break;
474
475 if ( c == '\n' )
476 break;
477
478 if ( c == '\r' )
479 continue;
480
481 buffer[count++] = c;
482 }
483
484 if ( count < buffer_size )
485 buffer[count] = 0;
486
487 return count;
488}
489
490/* parse a line from a configuration file. the line format is:
491
492 setting name: setting value
493
494 Any whitespace before setting name or value (after ':') is ignored.
495 A # as first non-whitespace character discards the whole line.
496 Function sets pointers to null-terminated setting name and value.
497 Returns false if no valid config entry was found.
498*/
499
500static bool settings_parseline(char* line, char** name, char** value)
501{
502 char* ptr;
503
504 while ( isspace(*line) )
505 line++;
506
507 if ( *line == '#' )
508 return false;
509
510 ptr = strchr(line, ':');
511 if ( !ptr )
512 return false;
513
514 *name = line;
515 *ptr = 0;
516 ptr++;
517 while (isspace(*ptr))
518 ptr++;
519 *value = ptr;
520 return true;
521}
522
523static void set_eq_sound(char* value, int type, int* setting)
524{
525 int num = atoi(value);
526
527 num = mpeg_phys2val(type, num);
528
529 if ((num > mpeg_sound_max(type)) ||
530 (num < mpeg_sound_min(type)))
531 {
532 num = mpeg_sound_default(type);
533 }
534
535 *setting = num;
536 mpeg_sound_set(type, num);
537}
538
465bool settings_load_eq(char* file) 539bool settings_load_eq(char* file)
466{ 540{
467 char buffer[512];
468 char buf_set[16];
469 char buf_disp[16];
470 char buf_val[8];
471 bool syntax_error = false;
472 int fd; 541 int fd;
473 int i; 542 char line[128];
474 int d = 0;
475 int vtype = 0;
476 int line = 0;
477
478 543
479 lcd_clear_display();
480 fd = open(file, O_RDONLY); 544 fd = open(file, O_RDONLY);
481 545 if (-1 == fd)
482 if (-1 != fd) 546 return false;
547
548 while (read_line(fd, line, sizeof line))
483 { 549 {
484 int numread = read(fd, buffer, sizeof(buffer) - 1); 550 char* name;
485 551 char* value;
486 if (numread > 0) { 552
487 buffer[numread] = 0; 553 if (!settings_parseline(line, &name, &value))
488 for(i=0;i<numread;i++) { 554 continue;
489 switch(buffer[i]) { 555
490 case '[': 556 if (!strcasecmp(name, "volume"))
491 vtype = 1; 557 set_eq_sound(value, SOUND_VOLUME, &global_settings.volume);
492 buf_set[0] = 0; 558 else if (!strcasecmp(name, "bass"))
493 d = 0; 559 set_eq_sound(value, SOUND_BASS, &global_settings.bass);
494 break; 560 else if (!strcasecmp(name, "treble"))
495 case ']': 561 set_eq_sound(value, SOUND_TREBLE, &global_settings.treble);
496 vtype = 2; 562 else if (!strcasecmp(name, "balance"))
497 buf_set[d] = 0; 563 set_eq_sound(value, SOUND_BALANCE, &global_settings.balance);
498 buf_val[0] = 0; 564 else if (!strcasecmp(name, "channels"))
499 d = 0; 565 set_eq_sound(value, SOUND_CHANNELS, &global_settings.bass);
500 break; 566#ifdef HAVE_MAS3587F
501 case '#': 567 else if (!strcasecmp(name, "loudness"))
502 buf_val[d] = 0; 568 set_eq_sound(value, SOUND_LOUDNESS, &global_settings.loudness);
503 vtype = 3; 569 else if (!strcasecmp(name, "bass boost"))
504 break; 570 set_eq_sound(value, SOUND_SUPERBASS, &global_settings.bass_boost);
505 default: 571 else if (!strcasecmp(name, "auto volume"))
506 switch(vtype) { 572 set_eq_sound(value, SOUND_AVC, &global_settings.avc);
507 case 1: 573#endif
508 buf_set[d++] = buffer[i];
509 break;
510 case 2:
511 buf_val[d++] = buffer[i];
512 break;
513 case 3:
514 snprintf(buf_disp,sizeof(buf_disp),"[%s]%s", buf_set, buf_val);
515 lcd_puts(0,line++ % MAX_LINES, buf_disp);
516 lcd_update();
517 sleep(HZ/2);
518 if (!strcasecmp(buf_set,"volume")) {
519 global_settings.volume = (atoi(buf_val)/2);
520 if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME) ||
521 global_settings.volume < mpeg_sound_min(SOUND_VOLUME)) {
522 global_settings.volume = mpeg_sound_default(SOUND_VOLUME);
523 syntax_error = true;
524 }
525 mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
526
527 } else
528 if (!strcasecmp(buf_set,"bass")) {
529 if (buf_val[0] == '-')
530 global_settings.bass = ((mpeg_sound_max(SOUND_BASS)/2)-atoi(buf_val+1));
531 else
532 global_settings.bass = (atoi(buf_val)+(mpeg_sound_max(SOUND_BASS)/2));
533 if (global_settings.bass > mpeg_sound_max(SOUND_BASS) ||
534 global_settings.bass < mpeg_sound_min(SOUND_BASS)) {
535 global_settings.bass = mpeg_sound_default(SOUND_BASS);
536 syntax_error = true;
537 }
538 mpeg_sound_set(SOUND_BASS, global_settings.bass);
539 } else
540 if (!strcasecmp(buf_set,"treble")) {
541 if (buf_val[0] == '-')
542 global_settings.treble = ((mpeg_sound_max(SOUND_TREBLE)/2)-atoi(buf_val+1));
543 else
544 global_settings.treble = (atoi(buf_val)+(mpeg_sound_max(SOUND_TREBLE)/2));
545 if (global_settings.treble > mpeg_sound_max(SOUND_TREBLE) ||
546 global_settings.treble < mpeg_sound_min(SOUND_TREBLE)) {
547 global_settings.treble = mpeg_sound_default(SOUND_TREBLE);
548 syntax_error = true;
549 }
550 mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
551 } else
552 if (!strcasecmp(buf_set,"balance")) {
553 if (buf_val[0] == '-')
554 global_settings.balance = -(atoi(buf_val+1)/2);
555 else
556 global_settings.balance = ((atoi(buf_val)/2));
557 if (global_settings.balance > mpeg_sound_max(SOUND_BALANCE) ||
558 global_settings.balance < mpeg_sound_min(SOUND_BALANCE)) {
559 global_settings.balance = mpeg_sound_default(SOUND_BALANCE);
560 syntax_error = true;
561 }
562 mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
563 } else
564 if (!strcasecmp(buf_set,"channels")) {
565 global_settings.channel_config = atoi(buf_val);
566 if (global_settings.channel_config > mpeg_sound_max(SOUND_CHANNELS) ||
567 global_settings.channel_config < mpeg_sound_min(SOUND_CHANNELS)) {
568 global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS);
569 syntax_error = true;
570 }
571 mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);
572 } else
573 if (!strcasecmp(buf_set,"loudness")) {
574 global_settings.loudness = atoi(buf_val);
575 if(global_settings.loudness > mpeg_sound_max(SOUND_LOUDNESS) ||
576 global_settings.loudness < mpeg_sound_min(SOUND_LOUDNESS)) {
577 global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS);
578 syntax_error = true;
579 }
580 mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness);
581 } else
582 if (!strcasecmp(buf_set,"bass boost")) {
583 global_settings.bass_boost = (atoi(buf_val)/10);
584 if(global_settings.bass_boost > mpeg_sound_max(SOUND_SUPERBASS) ||
585 global_settings.bass_boost < mpeg_sound_min(SOUND_SUPERBASS)) {
586 global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS);
587 syntax_error = true;
588 }
589 mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost);
590 } else if (!strcasecmp(buf_set,"auto volume")) {
591 global_settings.avc = atoi(buf_val);
592 if (global_settings.avc > mpeg_sound_max(SOUND_AVC) ||
593 global_settings.avc < mpeg_sound_min(SOUND_AVC)) {
594 global_settings.avc = mpeg_sound_default(SOUND_AVC);
595 syntax_error = true;
596 }
597 mpeg_sound_set(SOUND_AVC, global_settings.avc);
598 }
599 if (syntax_error) {
600 lcd_clear_display();
601 lcd_puts(0,1,"SyntaxError");
602 lcd_puts(0,2,buf_set);
603 lcd_update();
604 sleep(HZ);
605 syntax_error = false;
606 }
607 vtype = 0;
608 break;
609 }
610 break;
611 }
612 }
613 }
614 close(fd);
615 } 574 }
616 return(false); 575
576 close(fd);
577 return true;
617} 578}
618 579
619/* 580/*
diff --git a/docs/CUSTOM_EQ_FORMAT b/docs/CUSTOM_EQ_FORMAT
index e1ba622a0e..e1b0810bca 100644
--- a/docs/CUSTOM_EQ_FORMAT
+++ b/docs/CUSTOM_EQ_FORMAT
@@ -5,7 +5,6 @@ Description / General Info
5-------------------------- 5--------------------------
6* The Custom EQ is used on both the Rockbox Player and Recorder, in order to 6* The Custom EQ is used on both the Rockbox Player and Recorder, in order to
7 load, well, custom eq settings. 7 load, well, custom eq settings.
8* After editing the .eq file, you may need to reboot your Rockbox.
9 8
10File Location 9File Location
11------------- 10-------------
@@ -14,24 +13,31 @@ the filename must end in .eq
14 13
15Format Rules 14Format Rules
16------------ 15------------
17* Each setting must have it's own line 16* Each setting must have it's own line.
18* The setting you wish to change must be in brackets. 17* Lines starting with # are ignored.
19* The value must be immediately after the end bracket, with no spaces.
20* There must be a # immediately after the value, with no spaces
21* Any text after the # will be ignored
22* If a value is out of the acceptable range for the device, which can vary 18* If a value is out of the acceptable range for the device, which can vary
23 depending on the model, a Syntax Error will be displayed and the value 19 depending on the model, the value will be set to its default value.
24 will be set to the default value.
25 20
26Example File 21Example File
27------------ 22------------
28[volume]70# 0 to 100 23volume: 70
29[bass]11# player: -15 to 15, recorder: -12 to 12 24bass: 11
30[treble]12# player: -15 to 15, recorder: -12 to 12 25treble: 12
31[balance]0# -100 to 100 26balance: 0
32[channels]0# 0=Stereo, 1=Mono, 2=Mono Left, 3=Mono Right 27channels: 0
33[loudness]5# 0 to 17, recorder only! 28loudness: 5
34[bass boost]30# 0 to 100, recorder only! 29bass boost: 30
35[auto volume]0# 0=off, 1=2s, 2=4s, 3=8s, recorder only! 30auto volume: 0
36 31
37This sets each line to the respective values after it. Notice that you can put comments after the # \ No newline at end of file 32This sets each line to the respective values after it.
33
34Value ranges
35------------
36volume: 0 to 100
37bass: player: -15 to 15, recorder: -12 to 12
38treble: player: -15 to 15, recorder: -12 to 12
39balance: -100 to 100
40channels: 0=Stereo, 1=Mono, 2=Mono Left, 3=Mono Right
41loudness: 0 to 17 (recorder only)
42bass boost: 0 to 100 (recorder only)
43auto volume: 0=off, 1=2s, 2=4s, 3=8s (recorder only)
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index c6e95dd588..6e2cabe172 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -1757,6 +1757,51 @@ int mpeg_val2phys(int setting, int value)
1757 return result; 1757 return result;
1758} 1758}
1759 1759
1760int mpeg_phys2val(int setting, int value)
1761{
1762 int result = 0;
1763
1764 switch(setting)
1765 {
1766 case SOUND_VOLUME:
1767 result = value / 2;
1768 break;
1769
1770 case SOUND_BALANCE:
1771 result = value / 2;
1772 break;
1773
1774 case SOUND_BASS:
1775#ifdef HAVE_MAS3587F
1776 result = value + 12;
1777#else
1778 result = value + 15;
1779#endif
1780 break;
1781
1782 case SOUND_TREBLE:
1783#ifdef HAVE_MAS3587F
1784 result = value + 12;
1785#else
1786 result = value + 15;
1787#endif
1788 break;
1789
1790#ifdef HAVE_MAS3587F
1791 case SOUND_LOUDNESS:
1792 result = value;
1793 break;
1794
1795 case SOUND_SUPERBASS:
1796 result = value / 10;
1797 break;
1798#endif
1799 }
1800
1801 return result;
1802}
1803
1804
1760void mpeg_sound_channel_config(int configuration) 1805void mpeg_sound_channel_config(int configuration)
1761{ 1806{
1762#ifdef SIMULATOR 1807#ifdef SIMULATOR
diff --git a/firmware/mpeg.h b/firmware/mpeg.h
index a67ca922c4..4a92a2fbe9 100644
--- a/firmware/mpeg.h
+++ b/firmware/mpeg.h
@@ -37,6 +37,7 @@ int mpeg_sound_max(int setting);
37int mpeg_sound_default(int setting); 37int mpeg_sound_default(int setting);
38void mpeg_sound_channel_config(int configuration); 38void mpeg_sound_channel_config(int configuration);
39int mpeg_val2phys(int setting, int value); 39int mpeg_val2phys(int setting, int value);
40int mpeg_phys2val(int setting, int value);
40char *mpeg_sound_unit(int setting); 41char *mpeg_sound_unit(int setting);
41int mpeg_sound_numdecimals(int setting); 42int mpeg_sound_numdecimals(int setting);
42struct mp3entry* mpeg_current_track(void); 43struct mp3entry* mpeg_current_track(void);
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index ad0eb2df17..68e50223d0 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -63,7 +63,7 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall -mwindows
63APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall -mwindows 63APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall -mwindows
64 64
65FIRMSRCS = lcd-recorder.c power.c sprintf.c id3.c usb.c \ 65FIRMSRCS = lcd-recorder.c power.c sprintf.c id3.c usb.c \
66 mpeg.c powermgmt.c font.c sysfont.c 66 mpeg.c powermgmt.c font.c sysfont.c ctype.c
67 67
68APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ 68APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \
69 playlist.c showtext.c wps.c wps-display.c settings.c status.c \ 69 playlist.c showtext.c wps.c wps-display.c settings.c status.c \
@@ -221,6 +221,9 @@ $(OBJDIR)/mpeg.o: $(FIRMWAREDIR)/mpeg.c
221$(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c 221$(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c
222 $(CC) $(CFLAGS) -c $< -o $@ 222 $(CC) $(CFLAGS) -c $< -o $@
223 223
224$(OBJDIR)/ctype.o: $(COMMON)/ctype.c
225 $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@
226
224$(OBJDIR)/strtok.o: $(COMMON)/strtok.c 227$(OBJDIR)/strtok.o: $(COMMON)/strtok.c
225 $(CC) $(CFLAGS) -c $< -o $@ 228 $(CC) $(CFLAGS) -c $< -o $@
226 229
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index 81ddaf58a7..930de50d7b 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -78,7 +78,7 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall
78APPCFLAGS = $(DEBUG) $(DEFINES) -DAPPSVERSION=\"$(VERSION)\" $(APPINCLUDES) -W -Wall 78APPCFLAGS = $(DEBUG) $(DEFINES) -DAPPSVERSION=\"$(VERSION)\" $(APPINCLUDES) -W -Wall
79 79
80FIRMSRCS = lcd-recorder.c sprintf.c id3.c debug.c usb.c mpeg.c power.c\ 80FIRMSRCS = lcd-recorder.c sprintf.c id3.c debug.c usb.c mpeg.c power.c\
81 powermgmt.c font.c panic.c sysfont.c 81 powermgmt.c font.c panic.c sysfont.c ctype.c
82 82
83APPS = main.c tree.c menu.c credits.c main_menu.c language.c\ 83APPS = main.c tree.c menu.c credits.c main_menu.c language.c\
84 playlist.c showtext.c wps.c wps-display.c settings.c status.c icons.c\ 84 playlist.c showtext.c wps.c wps-display.c settings.c status.c icons.c\
@@ -263,6 +263,9 @@ $(OBJDIR)/mpeg.o: $(FIRMWAREDIR)/mpeg.c
263$(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c 263$(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c
264 $(CC) $(CFLAGS) -c $< -o $@ 264 $(CC) $(CFLAGS) -c $< -o $@
265 265
266$(OBJDIR)/ctype.o: $(COMMON)/ctype.c
267 $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@
268
266$(OBJDIR)/stubs.o: ../common/stubs.c 269$(OBJDIR)/stubs.o: ../common/stubs.c
267 $(CC) $(CFLAGS) -c $< -o $@ 270 $(CC) $(CFLAGS) -c $< -o $@
268 271