diff options
-rw-r--r-- | apps/main.c | 3 | ||||
-rw-r--r-- | apps/settings.c | 7 | ||||
-rw-r--r-- | apps/settings.h | 4 | ||||
-rw-r--r-- | apps/sound_menu.c | 10 | ||||
-rw-r--r-- | firmware/drivers/mas.h | 7 | ||||
-rw-r--r-- | firmware/mpeg.c | 39 | ||||
-rw-r--r-- | firmware/mpeg.h | 5 |
7 files changed, 67 insertions, 8 deletions
diff --git a/apps/main.c b/apps/main.c index caa5517c4d..38a0c878d8 100644 --- a/apps/main.c +++ b/apps/main.c @@ -150,7 +150,8 @@ void init(void) global_settings.bass, global_settings.treble, global_settings.loudness, - global_settings.bass_boost ); + global_settings.bass_boost, + global_settings.avc ); status_init(); usb_start_monitoring(); diff --git a/apps/settings.c b/apps/settings.c index 84ac584951..5eebc61b41 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -54,6 +54,7 @@ offset abs 0x0e 0x22 <shuffle mode & directory filter byte> 0x0f 0x23 <scroll speed & WPS display byte> 0x10 0x24 <playlist options byte> +0x11 0x25 <AVC byte> <all unused space filled with 0xff> @@ -216,6 +217,8 @@ int settings_save( void ) ((global_settings.scroll_speed << 3) | (global_settings.wps_display & 7)); + rtc_config_block[0x11] = (unsigned char)global_settings.avc; + memcpy(&rtc_config_block[0x24], &global_settings.total_uptime, 4); memcpy(&rtc_config_block[0x28], &global_settings.total_boots, 2); @@ -277,6 +280,9 @@ void settings_load(void) c = rtc_config_block[0xf] & 7; if (c != 7) global_settings.wps_display = c; + + if (rtc_config_block[0x11] != 0xFF) + global_settings.avc = rtc_config_block[0x11]; if (rtc_config_block[0x24] != 0xFF) memcpy(&global_settings.total_uptime, &rtc_config_block[0x24], 4); @@ -300,6 +306,7 @@ void settings_reset(void) { global_settings.treble = mpeg_sound_default(SOUND_TREBLE); global_settings.loudness = DEFAULT_LOUDNESS_SETTING; global_settings.bass_boost = DEFAULT_BASS_BOOST_SETTING; + global_settings.avc = DEFAULT_AVC_SETTING; global_settings.contrast = DEFAULT_CONTRAST_SETTING; global_settings.poweroff = DEFAULT_POWEROFF_SETTING; global_settings.backlight = DEFAULT_BACKLIGHT_SETTING; diff --git a/apps/settings.h b/apps/settings.h index 3921fb1f52..6a9f0ea636 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -38,7 +38,8 @@ struct user_settings int treble; /* treble eq: 0-100 0=low 100=high */ int loudness; /* loudness eq: 0-100 0=off 100=max */ int bass_boost; /* bass boost eq: 0-100 0=off 100=max */ - + int avc; /* auto volume correct: 0=disable, 1=2s 2=4s 3=8s */ + /* device settings */ int contrast; /* lcd contrast: 0-100 0=low 100=high */ @@ -94,6 +95,7 @@ extern struct user_settings global_settings; #define DEFAULT_TREBLE_SETTING 50/2 #define DEFAULT_LOUDNESS_SETTING 0 #define DEFAULT_BASS_BOOST_SETTING 0 +#define DEFAULT_AVC_SETTING 0 #define DEFAULT_CONTRAST_SETTING 0 #define DEFAULT_POWEROFF_SETTING 0 #define DEFAULT_BACKLIGHT_SETTING 5 diff --git a/apps/sound_menu.c b/apps/sound_menu.c index 015e8d08a9..2fd7a00946 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -128,6 +128,13 @@ static void bass_boost(void) { set_sound("Bass boost", &global_settings.bass_boost, SOUND_SUPERBASS); }; + +static void avc(void) +{ + char* names[] = { "off", "2s ", "4s ", "8s " }; + set_option("[AVC decay time]", &global_settings.avc, names, 4 ); + mpeg_sound_set(SOUND_AVC, global_settings.avc); +} #endif /* ARCHOS_RECORDER */ void sound_menu(void) @@ -139,7 +146,8 @@ void sound_menu(void) { "Treble", treble }, #ifdef ARCHOS_RECORDER { "Loudness", loudness }, - { "Bass Boost", bass_boost } + { "Bass Boost", bass_boost }, + { "AVC", avc } #endif }; diff --git a/firmware/drivers/mas.h b/firmware/drivers/mas.h index f5ab554ca1..5ccffdfd5b 100644 --- a/firmware/drivers/mas.h +++ b/firmware/drivers/mas.h @@ -60,11 +60,18 @@ #define MAS_REG_KPRESCALE 0xe7 #define MAS_REG_KBASS 0x6b #define MAS_REG_KTREBLE 0x6f +#ifdef ARCHOS_RECORDER #define MAS_REG_KMDB_SWITCH 0x21 #define MAS_REG_KMDB_STR 0x22 #define MAS_REG_KMDB_HAR 0x23 #define MAS_REG_KMDB_FC 0x24 #define MAS_REG_KLOUDNESS 0x1e +#define MAS_REG_QPEAK_L 0x0a +#define MAS_REG_QPEAK_R 0x0b +#define MAS_REG_DQPEAK_L 0x0c +#define MAS_REG_DQPEAK_R 0x0d +#define MAS_REG_KAVC 0x12 +#endif /* * MAS commands diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 82e30ca0ba..50a9789501 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -484,6 +484,7 @@ void IMIA1(void) static int new_file(bool next_track) { char *trackname; + int i; do { trackname = peek_next_track( next_track ? 1 : -1 ); @@ -503,6 +504,10 @@ static int new_file(bool next_track) mp3info(&(id3tags[last_tag].id3), trackname); id3tags[last_tag].mempos = mp3buf_write; last_tag++; + for(i = 0;i < last_tag;i++) + { + DEBUGF("nf: %d, %x\n", i, id3tags[i].mempos); + } } } } while ( mpeg_file < 0 ); @@ -800,10 +805,15 @@ static void mpeg_thread(void) case MPEG_TRACK_CHANGE: DEBUGF("Track change\n"); +#ifdef ARCHOS_RECORDER + /* Reset the AVC */ + mpeg_sound_set(SOUND_AVC, -1); +#endif /* shift array so index 0 is current track */ for (i=0; i<last_tag-1; i++) { id3tags[i] = id3tags[i+1]; + DEBUGF("tc: %d, %x\n", i, id3tags[i].mempos); } last_tag--; break; @@ -1038,6 +1048,28 @@ void mpeg_sound_set(int setting, int value) tmp = MAX(MIN(value * 4, 0x44), 0); mas_codec_writereg(MAS_REG_KLOUDNESS, (tmp & 0xff) << 8); break; + + case SOUND_AVC: + switch (value) { + case 1: /* 2s */ + tmp = (0x2 << 8) | (0x8 << 12); + break; + case 2: /* 4s */ + tmp = (0x4 << 8) | (0x8 << 12); + break; + case 3: /* 8s */ + tmp = (0x8 << 8) | (0x8 << 12); + break; + case -1: /* turn off and then turn on again to decay quickly */ + tmp = mas_codec_readreg(MAS_REG_KAVC); + mas_codec_writereg(MAS_REG_KAVC, 0); + break; + default: /* off */ + tmp = 0; + break; + } + mas_codec_writereg(MAS_REG_KAVC, tmp); + break; #endif } #endif /* SIMULATOR */ @@ -1082,16 +1114,16 @@ int mpeg_val2phys(int setting, int value) return result; } -void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost) +void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost, int avc) { #ifdef SIMULATOR - volume = bass = treble = loudness = bass_boost; + volume = bass = treble = loudness = bass_boost = avc; #else #ifdef ARCHOS_RECORDER int rc; unsigned long val; #else - loudness = bass_boost; + loudness = bass_boost = avc; #endif setup_sci0(); @@ -1158,6 +1190,7 @@ void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost) #ifdef ARCHOS_RECORDER mpeg_sound_set(SOUND_LOUDNESS, loudness); mpeg_sound_set(SOUND_SUPERBASS, bass_boost); + mpeg_sound_set(SOUND_AVC, avc); #endif #endif /* SIMULATOR */ } diff --git a/firmware/mpeg.h b/firmware/mpeg.h index 4150181620..6a86b3400d 100644 --- a/firmware/mpeg.h +++ b/firmware/mpeg.h @@ -21,7 +21,7 @@ #include <stdbool.h> -void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost); +void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost, int avc); void mpeg_play(char* trackname); void mpeg_stop(void); void mpeg_pause(void); @@ -46,7 +46,8 @@ struct mp3entry* mpeg_current_track(void); #ifdef ARCHOS_RECORDER #define SOUND_LOUDNESS 4 #define SOUND_SUPERBASS 5 -#define SOUND_NUMSETTINGS 6 +#define SOUND_AVC 6 +#define SOUND_NUMSETTINGS 7 #else #define SOUND_DEEMPH 4 #define SOUND_NUMSETTINGS 5 |