diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-07-25 15:55:22 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-07-25 15:55:22 +0000 |
commit | d731cdd0db2e5e0ba2272f89df47f44348943500 (patch) | |
tree | cbb5f68f6808c8e86d508c599375370d24a32f6d /firmware | |
parent | e4b9dbb9c5ccc69a09f6a696b269c6a52aad1def (diff) |
Automatic Volume Control for Recorder by Heikki Hannikainen
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1447 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/mas.h | 7 | ||||
-rw-r--r-- | firmware/mpeg.c | 39 | ||||
-rw-r--r-- | firmware/mpeg.h | 5 |
3 files changed, 46 insertions, 5 deletions
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 |