summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-11-06 23:12:11 +0000
committerJens Arnold <amiconn@rockbox.org>2005-11-06 23:12:11 +0000
commit8051a0b724bff718ce99acc0c45dd561d8d798d7 (patch)
treea09a44c1aeed92c313880671140c1f06c7a169e3
parent4d9be96a819206534594f79e856fbbd7880588d4 (diff)
Sound settings rework: * Put all fixed parameters (unit, decimals, step, min, max, default, set function) for the individual settings into one structure array. * Use the new individual sound setting functions where appropriate. * Added dummy sound setting functions and defined the codec type for the sims. Fixes wrong sound settings ranges in the simulators. * Code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7770 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c2
-rw-r--r--apps/plugins/alpine_cdc.c4
-rw-r--r--apps/recorder/radio.c4
-rw-r--r--apps/recorder/recording.c2
-rw-r--r--apps/settings.c8
-rw-r--r--apps/settings_menu.c2
-rw-r--r--apps/sound_menu.c22
-rw-r--r--apps/wps.c12
-rw-r--r--firmware/export/config-fmrecorder.h4
-rw-r--r--firmware/export/config-h100.h4
-rw-r--r--firmware/export/config-h120.h6
-rw-r--r--firmware/export/config-h300.h4
-rw-r--r--firmware/export/config-ondiofm.h6
-rw-r--r--firmware/export/config-ondiosp.h6
-rw-r--r--firmware/export/config-player.h10
-rw-r--r--firmware/export/config-recorder.h4
-rw-r--r--firmware/export/config-recorderv2.h6
-rw-r--r--firmware/export/sound.h82
-rw-r--r--firmware/mp3_playback.c4
-rw-r--r--firmware/mpeg.c27
-rw-r--r--firmware/sound.c364
21 files changed, 250 insertions, 333 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 61d0d62af8..8f300f5145 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1228,7 +1228,7 @@ void audio_play_start(int offset)
}
memset(&tracks, 0, sizeof(struct track_info) * MAX_TRACK);
- sound_set(SOUND_VOLUME, global_settings.volume);
+ sound_set_volume(global_settings.volume);
track_count = 0;
track_widx = 0;
track_ridx = 0;
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index 5dd8b4a952..be13775216 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -1045,9 +1045,11 @@ void sound_neutral(void)
rb->sound_set(SOUND_TREBLE, 0);
rb->sound_set(SOUND_BALANCE, 0);
rb->sound_set(SOUND_VOLUME, 92); /* 0 dB */
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
rb->sound_set(SOUND_LOUDNESS, 0);
rb->sound_set(SOUND_SUPERBASS, 0);
rb->sound_set(SOUND_AVC, 0);
+#endif
}
/* return to user settings */
@@ -1057,9 +1059,11 @@ void sound_normal(void)
rb->sound_set(SOUND_TREBLE, rb->global_settings->treble);
rb->sound_set(SOUND_BALANCE, rb->global_settings->balance);
rb->sound_set(SOUND_VOLUME, rb->global_settings->volume);
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
rb->sound_set(SOUND_LOUDNESS, rb->global_settings->loudness);
rb->sound_set(SOUND_SUPERBASS, rb->global_settings->superbass);
rb->sound_set(SOUND_AVC, rb->global_settings->avc);
+#endif
}
/* the thread running it all */
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 678da80034..443bb3192f 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -410,7 +410,7 @@ bool radio_screen(void)
global_settings.volume++;
if(global_settings.volume > sound_max(SOUND_VOLUME))
global_settings.volume = sound_max(SOUND_VOLUME);
- sound_set(SOUND_VOLUME, global_settings.volume);
+ sound_set_volume(global_settings.volume);
update_screen = true;
settings_save();
break;
@@ -420,7 +420,7 @@ bool radio_screen(void)
global_settings.volume--;
if(global_settings.volume < sound_min(SOUND_VOLUME))
global_settings.volume = sound_min(SOUND_VOLUME);
- sound_set(SOUND_VOLUME, global_settings.volume);
+ sound_set_volume(global_settings.volume);
update_screen = true;
settings_save();
break;
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 84f99653da..b70e7b64ed 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -291,7 +291,7 @@ bool recording_screen(void)
#endif
mpeg_init_recording();
- sound_set(SOUND_VOLUME, global_settings.volume);
+ sound_set_volume(global_settings.volume);
/* Yes, we use the D/A for monitoring */
peak_meter_playback(true);
diff --git a/apps/settings.c b/apps/settings.c
index 5eb434b31d..5eb7dcedaf 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -827,7 +827,7 @@ void settings_apply(void)
backlight_set_fade_out(global_settings.backlight_fade_out);
#endif
ata_spindown(global_settings.disk_spindown);
-#if CONFIG_CODEC == MAS3507D
+#if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR)
dac_line_in(global_settings.line_in);
#endif
mpeg_id3_options(global_settings.id3_v1_first);
@@ -1329,16 +1329,18 @@ void settings_reset(void) {
global_settings.balance = sound_default(SOUND_BALANCE);
global_settings.bass = sound_default(SOUND_BASS);
global_settings.treble = sound_default(SOUND_TREBLE);
- global_settings.loudness = sound_default(SOUND_LOUDNESS);
- global_settings.avc = sound_default(SOUND_AVC);
global_settings.channel_config = sound_default(SOUND_CHANNELS);
global_settings.stereo_width = sound_default(SOUND_STEREO_WIDTH);
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+ global_settings.loudness = sound_default(SOUND_LOUDNESS);
+ global_settings.avc = sound_default(SOUND_AVC);
global_settings.mdb_strength = sound_default(SOUND_MDB_STRENGTH);
global_settings.mdb_harmonics = sound_default(SOUND_MDB_HARMONICS);
global_settings.mdb_center = sound_default(SOUND_MDB_CENTER);
global_settings.mdb_shape = sound_default(SOUND_MDB_SHAPE);
global_settings.mdb_enable = sound_default(SOUND_MDB_ENABLE);
global_settings.superbass = sound_default(SOUND_SUPERBASS);
+#endif
global_settings.contrast = lcd_default_contrast();
global_settings.wps_file[0] = '\0';
global_settings.font_file[0] = '\0';
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 65e40f9f10..22ed9c7fec 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -882,7 +882,9 @@ static bool poweroff(void)
static bool line_in(void)
{
bool rc = set_bool(str(LANG_LINE_IN), &global_settings.line_in);
+#ifndef SIMULATOR
dac_line_in(global_settings.line_in);
+#endif
return rc;
}
#endif
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index d9d2194045..766372471e 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -62,13 +62,13 @@ bool set_sound(const char* string,
int steps = sound_steps(setting);
int min = sound_min(setting);
int max = sound_max(setting);
- void(*sound_callback)(int)=sound_get_fn(setting);
+ sound_set_type* sound_callback = sound_get_fn(setting);
if (*unit == 'd') /* crude reconstruction */
talkunit = UNIT_DB;
else if (*unit == '%')
talkunit = UNIT_PERCENT;
else if (*unit == 'H')
- talkunit = UNIT_HERTZ;
+ talkunit = UNIT_HERTZ;
if(!numdec)
return set_int(string, unit, talkunit, variable, sound_callback,
steps, min, max, NULL );
@@ -134,7 +134,7 @@ static bool mdb_shape(void)
static void set_mdb_enable(bool value)
{
- sound_set(SOUND_MDB_ENABLE, (int)value);
+ sound_set_mdb_enable((int)value);
}
static bool mdb_enable(void)
@@ -148,7 +148,7 @@ static bool mdb_enable(void)
static void set_superbass(bool value)
{
- sound_set(SOUND_SUPERBASS, (int)value);
+ sound_set_superbass((int)value);
}
static bool superbass(void)
@@ -160,11 +160,6 @@ static bool superbass(void)
set_superbass);
}
-static void set_avc(int val)
-{
- sound_set(SOUND_AVC, val);
-}
-
static bool avc(void)
{
static const struct opt_items names[] = {
@@ -175,7 +170,7 @@ static bool avc(void)
{ "8s", TALK_ID(8, UNIT_SEC) }
};
return set_option(str(LANG_DECAY), &global_settings.avc, INT,
- names, 5, set_avc);
+ names, 5, sound_set_avc);
}
#endif
@@ -317,11 +312,6 @@ static bool reconstartup(void)
#endif /* MAS3587F */
-static void set_chanconf(int val)
-{
- sound_set(SOUND_CHANNELS, val);
-}
-
static bool chanconf(void)
{
static const struct opt_items names[] = {
@@ -333,7 +323,7 @@ static bool chanconf(void)
{ STR(LANG_CHANNEL_KARAOKE) }
};
return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT,
- names, 6, set_chanconf );
+ names, 6, sound_set_channels);
}
static bool stereo_width(void)
diff --git a/apps/wps.c b/apps/wps.c
index ca6e394881..7a9a5de60b 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -77,7 +77,7 @@ static bool setvol(void)
global_settings.volume = sound_min(SOUND_VOLUME);
if (global_settings.volume > sound_max(SOUND_VOLUME))
global_settings.volume = sound_max(SOUND_VOLUME);
- sound_set(SOUND_VOLUME, global_settings.volume);
+ sound_set_volume(global_settings.volume);
status_draw(false);
wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
settings_save();
@@ -267,7 +267,7 @@ static void fade(bool fade_in)
unsigned fp_volume = 0;
/* zero out the sound */
- sound_set(SOUND_VOLUME, 0);
+ sound_set_volume(0);
sleep(HZ/10); /* let audio thread run */
audio_resume();
@@ -275,9 +275,9 @@ static void fade(bool fade_in)
while (fp_volume < fp_global_vol) {
fp_volume += fp_step;
sleep(1);
- sound_set(SOUND_VOLUME, fp_volume >> 8);
+ sound_set_volume(fp_volume >> 8);
}
- sound_set(SOUND_VOLUME, global_settings.volume);
+ sound_set_volume(global_settings.volume);
}
else {
/* fade out */
@@ -286,7 +286,7 @@ static void fade(bool fade_in)
while (fp_volume > fp_step) {
fp_volume -= fp_step;
sleep(1);
- sound_set(SOUND_VOLUME, fp_volume >> 8);
+ sound_set_volume(fp_volume >> 8);
}
audio_pause();
#ifndef SIMULATOR
@@ -296,7 +296,7 @@ static void fade(bool fade_in)
sleep(HZ/10);
/* reset volume to what it was before the fade */
- sound_set(SOUND_VOLUME, global_settings.volume);
+ sound_set_volume(global_settings.volume);
}
}
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h
index 0df6579a92..8de7869d50 100644
--- a/firmware/export/config-fmrecorder.h
+++ b/firmware/export/config-fmrecorder.h
@@ -26,11 +26,11 @@
#define AB_REPEAT_ENABLE 1
-#ifndef SIMULATOR
-
/* Define this if you have a MAS3587F */
#define CONFIG_CODEC MAS3587F
+#ifndef SIMULATOR
+
/* Define this if you have a SH7034 */
#define CONFIG_CPU SH7034
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index 07b8f7fa77..e5de9cd19b 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -50,6 +50,8 @@
#define CONFIG_TUNER TEA5767
#define CONFIG_TUNER_XTAL 32768
+#define HAVE_UDA1380
+
#ifndef SIMULATOR
/* Define this if you have a Motorola SCF5249 */
@@ -58,8 +60,6 @@
/* Define this if you want to use coldfire's i2c interface */
#define CONFIG_I2C I2C_COLDFIRE
-#define HAVE_UDA1380
-
/* Type of mobile power */
#define CONFIG_BATTERY BATT_LIPOL1300
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h
index d0625189ca..610dd848dc 100644
--- a/firmware/export/config-h120.h
+++ b/firmware/export/config-h120.h
@@ -46,6 +46,8 @@
#define CONFIG_TUNER TEA5767
#define CONFIG_TUNER_XTAL 32768
+#define HAVE_UDA1380
+
#ifndef SIMULATOR
/* Define this if you have a Motorola SCF5249 */
@@ -54,9 +56,6 @@
/* Define this if you want to use coldfire's i2c interface */
#define CONFIG_I2C I2C_COLDFIRE
-#define HAVE_UDA1380
-
-/* Type of mobile power */
#define CONFIG_BATTERY BATT_LIPOL1300
#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
@@ -97,3 +96,4 @@
/* Define this if you can control the S/PDIF power */
#define HAVE_SPDIF_POWER
+
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index 1de415830e..5deeef8a43 100644
--- a/firmware/export/config-h300.h
+++ b/firmware/export/config-h300.h
@@ -39,6 +39,8 @@
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0xC0000
+#define HAVE_UDA1380
+
#ifndef SIMULATOR
/* Define this if you have a Motorola SCF5249 */
@@ -47,8 +49,6 @@
/* Define this if you want to use coldfire's i2c interface */
#define CONFIG_I2C I2C_COLDFIRE
-#define HAVE_UDA1380
-
/* Type of mobile power */
#define CONFIG_BATTERY BATT_LIPOL1300
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h
index 46ef98d51c..d0e6900499 100644
--- a/firmware/export/config-ondiofm.h
+++ b/firmware/export/config-ondiofm.h
@@ -22,14 +22,14 @@
#define CONFIG_TUNER (S1A0903X01 | TEA5767) /* to be decided at runtime */
#define CONFIG_TUNER_XTAL 13000000
+/* Define this if you have a MAS3587F */
+#define CONFIG_CODEC MAS3587F
+
#ifndef SIMULATOR
/* Define this if you have a SH7034 */
#define CONFIG_CPU SH7034
-/* Define this if you have a MAS3587F */
-#define CONFIG_CODEC MAS3587F
-
/* Define this to the CPU frequency */
#define CPU_FREQ 12000000
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h
index 120369243e..41490f3e3e 100644
--- a/firmware/export/config-ondiosp.h
+++ b/firmware/export/config-ondiosp.h
@@ -15,14 +15,14 @@
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x8000
+/* Define this if you have a MAS3539F */
+#define CONFIG_CODEC MAS3539F
+
#ifndef SIMULATOR
/* Define this if you have a SH7034 */
#define CONFIG_CPU SH7034
-/* Define this if you have a MAS3539F */
-#define CONFIG_CODEC MAS3539F
-
/* Define this to the CPU frequency */
#define CPU_FREQ 12000000
diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h
index d5ab70fa42..e12e2234e1 100644
--- a/firmware/export/config-player.h
+++ b/firmware/export/config-player.h
@@ -14,17 +14,17 @@
#define AB_REPEAT_ENABLE 1
-#ifndef SIMULATOR
-
-/* Define this if you have a SH7034 */
-#define CONFIG_CPU SH7034
-
/* Define this if you have a MAS3507D */
#define CONFIG_CODEC MAS3507D
/* Define this if you have a DAC3550A */
#define HAVE_DAC3550A
+#ifndef SIMULATOR
+
+/* Define this if you have a SH7034 */
+#define CONFIG_CPU SH7034
+
/* Define this if you need to power on ATA */
#define NEEDS_ATA_POWER_ON
diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h
index 1874ce192b..367951d79a 100644
--- a/firmware/export/config-recorder.h
+++ b/firmware/export/config-recorder.h
@@ -20,11 +20,11 @@
#define AB_REPEAT_ENABLE 1
-#ifndef SIMULATOR
-
/* Define this if you have a MAS3587F */
#define CONFIG_CODEC MAS3587F
+#ifndef SIMULATOR
+
/* Define this if you have a SH7034 */
#define CONFIG_CPU SH7034
diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h
index 74ac021c42..95a428fe84 100644
--- a/firmware/export/config-recorderv2.h
+++ b/firmware/export/config-recorderv2.h
@@ -25,12 +25,12 @@
#ifndef SIMULATOR
-/* Define this if you have a SH7034 */
-#define CONFIG_CPU SH7034
-
/* Define this if you have a MAS3587F */
#define CONFIG_CODEC MAS3587F
+/* Define this if you have a SH7034 */
+#define CONFIG_CPU SH7034
+
/* Define this if you have a FM Recorder key system */
#define HAVE_FMADC 1
diff --git a/firmware/export/sound.h b/firmware/export/sound.h
index ed8a151c9b..9907462dc8 100644
--- a/firmware/export/sound.h
+++ b/firmware/export/sound.h
@@ -19,37 +19,55 @@
#ifndef SOUND_H
#define SOUND_H
-#define SOUND_VOLUME 0
-#define SOUND_BASS 1
-#define SOUND_TREBLE 2
-#define SOUND_BALANCE 3
-#define SOUND_LOUDNESS 4
-#define SOUND_AVC 5
-#define SOUND_CHANNELS 6
-#define SOUND_STEREO_WIDTH 7
-#define SOUND_LEFT_GAIN 8
-#define SOUND_RIGHT_GAIN 9
-#define SOUND_MIC_GAIN 10
-#define SOUND_MDB_STRENGTH 11
-#define SOUND_MDB_HARMONICS 12
-#define SOUND_MDB_CENTER 13
-#define SOUND_MDB_SHAPE 14
-#define SOUND_MDB_ENABLE 15
-#define SOUND_SUPERBASS 16
-#define SOUND_NUMSETTINGS 17
+enum {
+ SOUND_VOLUME = 0,
+ SOUND_BASS,
+ SOUND_TREBLE,
+ SOUND_BALANCE,
+ SOUND_CHANNELS,
+ SOUND_STEREO_WIDTH,
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+ SOUND_LOUDNESS,
+ SOUND_AVC,
+ SOUND_MDB_STRENGTH,
+ SOUND_MDB_HARMONICS,
+ SOUND_MDB_CENTER,
+ SOUND_MDB_SHAPE,
+ SOUND_MDB_ENABLE,
+ SOUND_SUPERBASS,
+#endif
+#if CONFIG_CODEC == MAS3587F
+ SOUND_LEFT_GAIN,
+ SOUND_RIGHT_GAIN,
+ SOUND_MIC_GAIN,
+#endif
+};
-#define SOUND_CHAN_STEREO 0
-#define SOUND_CHAN_MONO 1
-#define SOUND_CHAN_CUSTOM 2
-#define SOUND_CHAN_MONO_LEFT 3
-#define SOUND_CHAN_MONO_RIGHT 4
-#define SOUND_CHAN_KARAOKE 5
+enum {
+ SOUND_CHAN_STEREO = 0,
+ SOUND_CHAN_MONO,
+ SOUND_CHAN_CUSTOM,
+ SOUND_CHAN_MONO_LEFT,
+ SOUND_CHAN_MONO_RIGHT,
+ SOUND_CHAN_KARAOKE,
+};
+
+typedef void sound_set_type(int value);
+
+const char *sound_unit(int setting);
+int sound_numdecimals(int setting);
+int sound_steps(int setting);
+int sound_min(int setting);
+int sound_max(int setting);
+int sound_default(int setting);
+sound_set_type* sound_get_fn(int setting);
-#ifndef SIMULATOR
void sound_set_volume(int value);
void sound_set_balance(int value);
void sound_set_bass(int value);
void sound_set_treble(int value);
+void sound_set_channels(int value);
+void sound_set_stereo_width(int value);
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
void sound_set_loudness(int value);
void sound_set_avc(int value);
@@ -60,21 +78,11 @@ void sound_set_mdb_shape(int value);
void sound_set_mdb_enable(int value);
void sound_set_superbass(int value);
#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
-void sound_set_channels(int value);
-void sound_set_stereo_width(int value);
-#endif
-void (*sound_get_fn(int setting))(int value);
void sound_set(int setting, int value);
-int sound_min(int setting);
-int sound_max(int setting);
-int sound_default(int setting);
-void sound_channel_config(int configuration);
int sound_val2phys(int setting, int value);
-const char *sound_unit(int setting);
-int sound_numdecimals(int setting);
-int sound_steps(int setting);
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || defined(SIMULATOR)
+
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
void sound_set_pitch(int permille);
int sound_get_pitch(void);
#endif
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index b7114007b9..27392531bd 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -44,7 +44,7 @@ enum
} mpeg_mode;
#endif /* #ifdef MAS3587F */
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)) && !defined(SIMULATOR)
extern unsigned long shadow_io_control_main;
extern unsigned shadow_codec_reg0;
#endif
@@ -258,7 +258,6 @@ static void setup_sci0(void)
/* Enable Tx (only!) */
SCR0 |= 0x20;
}
-#endif /* SIMULATOR */
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
static void init_playback(void)
@@ -323,6 +322,7 @@ static void init_playback(void)
DEBUGF("MAS Decoding application started\n");
}
#endif /* #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
+#endif /* SIMULATOR */
void mp3_init(int volume, int bass, int treble, int balance, int loudness,
int avc, int channel_config, int stereo_width,
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 9d1aa3b9d6..3311fed43a 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -221,7 +221,7 @@ static int get_playable_space(void);
static int get_unswapped_space(void);
#endif /* !SIMULATOR */
-#if CONFIG_CODEC == MAS3587F
+#if (CONFIG_CODEC == MAS3587F) && !defined(SIMULATOR)
static void init_recording(void);
static void prepend_header(void);
static void update_header(void);
@@ -231,7 +231,7 @@ static void stop_recording(void);
static int get_unsaved_space(void);
static void pause_recording(void);
static void resume_recording(void);
-#endif /* CONFIG_CODEC == MAS3587F */
+#endif /* (CONFIG_CODEC == MAS3587F) && !defined(SIMULATOR) */
#ifndef SIMULATOR
@@ -2085,6 +2085,7 @@ bool audio_has_changed_track(void)
}
#if CONFIG_CODEC == MAS3587F
+#ifndef SIMULATOR
void audio_init_playback(void)
{
init_playback_done = false;
@@ -2575,20 +2576,9 @@ unsigned long mpeg_num_recorded_bytes(void)
return 0;
}
-#elif defined(SIMULATOR)
-
-/* dummies coming up
+#else /* SIMULATOR */
-NOTE: when we implment these functions for real for software coded targets,
-these dummies shall remain for the simulator */
-
-void bitswap(unsigned char *data, int length)
-{
- /* a dummy */
- /* this ought to be useless */
- (void)data;
- (void)length;
-}
+/* dummies coming up */
void audio_init_playback(void)
{
@@ -2651,7 +2641,8 @@ void mpeg_set_recording_options(int frequency, int quality,
(void)editable;
(void)prerecord_time;
}
-#endif /* CONFIG_CODEC == MAS3587F; SIMULATOR */
+#endif /* SIMULATOR */
+#endif /* CONFIG_CODEC == MAS3587F */
void audio_play(int offset)
{
@@ -2807,7 +2798,7 @@ int audio_status(void)
if(paused)
ret |= AUDIO_STATUS_PAUSE;
-#if CONFIG_CODEC == MAS3587F
+#if (CONFIG_CODEC == MAS3587F) && !defined(SIMULATOR)
if(is_recording && !is_prerecording)
ret |= AUDIO_STATUS_RECORD;
@@ -2867,7 +2858,7 @@ void audio_init(void)
memset(trackdata, sizeof(trackdata), 0);
-#if CONFIG_CODEC == MAS3587F
+#if (CONFIG_CODEC == MAS3587F) && !defined(SIMULATOR)
if(read_hw_mask() & PR_ACTIVE_HIGH)
and_b(~0x08, &PADRH);
else
diff --git a/firmware/sound.c b/firmware/sound.c
index c6f1bb6147..9ed3283906 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -38,196 +38,92 @@
#ifndef SIMULATOR
extern bool audio_is_initialized;
-#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
extern unsigned long shadow_io_control_main;
extern unsigned shadow_codec_reg0;
#endif
+#endif /* SIMULATOR */
-static const char* const units[] =
-{
- "%", /* Volume */
- "dB", /* Bass */
- "dB", /* Treble */
- "%", /* Balance */
- "dB", /* Loudness */
- "", /* AVC */
- "", /* Channels */
- "%", /* Stereo width */
- "dB", /* Left gain */
- "dB", /* Right gain */
- "dB", /* Mic gain */
- "dB", /* MDB Strength */
- "%", /* MDB Harmonics */
- "Hz", /* MDB Center */
- "Hz", /* MDB Shape */
- "", /* MDB Enable */
- "", /* Super bass */
-};
-
-static const int numdecimals[] =
-{
- 0, /* Volume */
- 0, /* Bass */
- 0, /* Treble */
- 0, /* Balance */
- 0, /* Loudness */
- 0, /* AVC */
- 0, /* Channels */
- 0, /* Stereo width */
- 1, /* Left gain */
- 1, /* Right gain */
- 1, /* Mic gain */
- 0, /* MDB Strength */
- 0, /* MDB Harmonics */
- 0, /* MDB Center */
- 0, /* MDB Shape */
- 0, /* MDB Enable */
- 0, /* Super bass */
-};
-
-static const int steps[] =
-{
- 1, /* Volume */
-#ifdef HAVE_UDA1380
- 2, /* Bass */
- 2, /* Treble */
-#else
- 1, /* Bass */
- 1, /* Treble */
-#endif
- 1, /* Balance */
- 1, /* Loudness */
- 1, /* AVC */
- 1, /* Channels */
- 1, /* Stereo width */
- 1, /* Left gain */
- 1, /* Right gain */
- 1, /* Mic gain */
- 1, /* MDB Strength */
- 1, /* MDB Harmonics */
- 10, /* MDB Center */
- 10, /* MDB Shape */
- 1, /* MDB Enable */
- 1, /* Super bass */
+struct sound_settings_info {
+ const char *unit;
+ int numdecimals;
+ int steps;
+ int minval;
+ int maxval;
+ int defaultval;
+ sound_set_type *setfn;
};
-static const int minval[] =
-{
- 0, /* Volume */
+static const struct sound_settings_info sound_settings_table[] = {
+ [SOUND_VOLUME] = {"%", 0, 1, 0, 100, 70, sound_set_volume},
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- -12, /* Bass */
- -12, /* Treble */
+ [SOUND_BASS] = {"dB", 0, 1, -12, 12, 6, sound_set_bass},
+ [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 6, sound_set_treble},
#elif defined(HAVE_UDA1380)
- 0, /* Bass */
- 0, /* Treble */
-#else
- -15, /* Bass */
- -15, /* Treble */
+ [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0, sound_set_bass},
+ [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0, sound_set_treble},
+#else /* MAS3507D */
+ [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass},
+ [SOUND_TREBLE] = {"dB", 0, 1, -15, 15, 7, sound_set_treble},
#endif
- -100, /* Balance */
- 0, /* Loudness */
- -1, /* AVC */
- 0, /* Channels */
- 0, /* Stereo width */
- 0, /* Left gain */
- 0, /* Right gain */
- 0, /* Mic gain */
- 0, /* MDB Strength */
- 0, /* MDB Harmonics */
- 20, /* MDB Center */
- 50, /* MDB Shape */
- 0, /* MDB Enable */
- 0, /* Super bass */
-};
-
-static const int maxval[] =
-{
- 100, /* Volume */
+ [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0, sound_set_balance},
+ [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0, sound_set_channels},
+ [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100, sound_set_stereo_width},
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- 12, /* Bass */
- 12, /* Treble */
-#elif defined(HAVE_UDA1380)
- 24, /* Bass */
- 6, /* Treble */
-#else
- 15, /* Bass */
- 15, /* Treble */
+ [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0, sound_set_loudness},
+ [SOUND_AVC] = {"", 0, 1, -1, 4, 0, sound_set_avc},
+ [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48, sound_set_mdb_strength},
+ [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50, sound_set_mdb_harmonics},
+ [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60, sound_set_mdb_center},
+ [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90, sound_set_mdb_shape},
+ [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0, sound_set_mdb_enable},
+ [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0, sound_set_superbass},
#endif
- 100, /* Balance */
- 17, /* Loudness */
- 4, /* AVC */
- 5, /* Channels */
- 255, /* Stereo width */
- 15, /* Left gain */
- 15, /* Right gain */
- 15, /* Mic gain */
- 127, /* MDB Strength */
- 100, /* MDB Harmonics */
- 300, /* MDB Center */
- 300, /* MDB Shape */
- 1, /* MDB Enable */
- 1, /* Super bass */
-};
-
-static const int defaultval[] =
-{
- 70, /* Volume */
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- 6, /* Bass */
- 6, /* Treble */
-#elif defined(HAVE_UDA1380)
- 0, /* Bass */
- 0, /* Treble */
-#else
- 7, /* Bass */
- 7, /* Treble */
+#if CONFIG_CODEC == MAS3587F
+ [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL},
+ [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL},
+ [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL},
#endif
- 0, /* Balance */
- 0, /* Loudness */
- 0, /* AVC */
- 0, /* Channels */
- 100, /* Stereo width */
- 8, /* Left gain */
- 8, /* Right gain */
- 2, /* Mic gain */
- 50, /* MDB Strength */
- 48, /* MDB Harmonics */
- 60, /* MDB Center */
- 90, /* MDB Shape */
- 0, /* MDB Enable */
- 0, /* Super bass */
};
const char *sound_unit(int setting)
{
- return units[setting];
+ return sound_settings_table[setting].unit;
}
int sound_numdecimals(int setting)
{
- return numdecimals[setting];
+ return sound_settings_table[setting].numdecimals;
}
int sound_steps(int setting)
{
- return steps[setting];
+ return sound_settings_table[setting].steps;
}
int sound_min(int setting)
{
- return minval[setting];
+ return sound_settings_table[setting].minval;
}
int sound_max(int setting)
{
- return maxval[setting];
+ return sound_settings_table[setting].maxval;
}
int sound_default(int setting)
{
- return defaultval[setting];
+ return sound_settings_table[setting].defaultval;
+}
+
+sound_set_type* sound_get_fn(int setting)
+{
+ if ((unsigned)setting < (sizeof(sound_settings_table)
+ / sizeof(struct sound_settings_info)))
+ return sound_settings_table[setting].setfn;
+ else
+ return NULL;
}
#ifndef SIMULATOR
@@ -487,15 +383,12 @@ static void set_channel_config(void)
mas_writemem(MAS_BANK_D1, 0x7fb, &val_rr, 1); /* RR */
#endif
}
-#endif /* !SIMULATOR */
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
unsigned long mdb_shape_shadow = 0;
unsigned long loudness_shadow = 0;
#endif
-#ifndef SIMULATOR
-
void sound_set_volume(int value)
{
if(!audio_is_initialized)
@@ -506,7 +399,7 @@ void sound_set_volume(int value)
#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380
current_volume = VOLUME_MIN + (value * VOLUME_RANGE / 100);
set_prescaled_volume(); /* tenth of dB */
-#endif
+#endif
}
void sound_set_balance(int value)
@@ -519,7 +412,7 @@ void sound_set_balance(int value)
#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380
current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
set_prescaled_volume();
-#endif
+#endif
}
void sound_set_bass(int value)
@@ -537,7 +430,7 @@ void sound_set_bass(int value)
uda1380_set_bass(value >> 1);
current_bass = value * 10;
set_prescaled_volume();
-#endif
+#endif
}
void sound_set_treble(int value)
@@ -555,7 +448,24 @@ void sound_set_treble(int value)
uda1380_set_treble(value >> 1);
current_treble = value * 10;
set_prescaled_volume();
-#endif
+#endif
+}
+
+void sound_set_channels(int value)
+{
+ if(!audio_is_initialized)
+ return;
+ channel_configuration = value;
+ set_channel_config();
+}
+
+void sound_set_stereo_width(int value)
+{
+ if(!audio_is_initialized)
+ return;
+ stereo_width = value;
+ if (channel_configuration == SOUND_CHAN_CUSTOM)
+ set_channel_config();
}
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
@@ -594,14 +504,14 @@ void sound_set_avc(int value)
tmp = 0;
break;
}
- mas_codec_writereg(MAS_REG_KAVC, tmp);
+ mas_codec_writereg(MAS_REG_KAVC, tmp);
}
void sound_set_mdb_strength(int value)
{
if(!audio_is_initialized)
return;
- mas_codec_writereg(MAS_REG_KMDB_STR, (value & 0x7f) << 8);
+ mas_codec_writereg(MAS_REG_KMDB_STR, (value & 0x7f) << 8);
}
void sound_set_mdb_harmonics(int value)
@@ -644,83 +554,92 @@ void sound_set_superbass(int value)
}
#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
+#else /* SIMULATOR */
+void sound_set_volume(int value)
+{
+ (void)value;
+}
+
+void sound_set_balance(int value)
+{
+ (void)value;
+}
+
+void sound_set_bass(int value)
+{
+ (void)value;
+}
+
+void sound_set_treble(int value)
+{
+ (void)value;
+}
+
void sound_set_channels(int value)
{
- if(!audio_is_initialized)
- return;
- channel_configuration = value;
- set_channel_config();
+ (void)value;
}
void sound_set_stereo_width(int value)
{
- if(!audio_is_initialized)
- return;
- stereo_width = value;
- if (channel_configuration == SOUND_CHAN_CUSTOM)
- set_channel_config();
+ (void)value;
}
-#endif /* SIMULATOR */
-void (*sound_get_fn(int setting))(int value)
-{
-#ifdef SIMULATOR
- (void)setting;
- return NULL;
-#else
- if(!audio_is_initialized)
- return NULL;
- switch(setting)
- {
- case SOUND_VOLUME:
- return &sound_set_volume;
- case SOUND_BALANCE:
- return &sound_set_balance;
- case SOUND_BASS:
- return &sound_set_bass;
- case SOUND_TREBLE:
- return &sound_set_treble;
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- case SOUND_LOUDNESS:
- return &sound_set_loudness;
- case SOUND_AVC:
- return &sound_set_avc;
- case SOUND_MDB_STRENGTH:
- return &sound_set_mdb_strength;
- case SOUND_MDB_HARMONICS:
- return &sound_set_mdb_harmonics;
- case SOUND_MDB_CENTER:
- return &sound_set_mdb_center;
- case SOUND_MDB_SHAPE:
- return &sound_set_mdb_shape;
- case SOUND_MDB_ENABLE:
- return &sound_set_mdb_enable;
- case SOUND_SUPERBASS:
- return &sound_set_superbass;
-#endif
- case SOUND_CHANNELS:
- return &sound_set_channels;
- case SOUND_STEREO_WIDTH:
- return &sound_set_stereo_width;
- default :
- return NULL;
- }
-#endif /* SIMULATOR */
+void sound_set_loudness(int value)
+{
+ (void)value;
}
-void sound_set(int setting, int value)
+void sound_set_avc(int value)
+{
+ (void)value;
+}
+
+void sound_set_mdb_strength(int value)
{
+ (void)value;
+}
- void (*sound_set_val)(int)=sound_get_fn(setting);
- if(sound_set_val)
+void sound_set_mdb_harmonics(int value)
+{
+ (void)value;
+}
+
+void sound_set_mdb_center(int value)
+{
+ (void)value;
+}
+
+void sound_set_mdb_shape(int value)
+{
+ (void)value;
+}
+
+void sound_set_mdb_enable(int value)
+{
+ (void)value;
+}
+
+void sound_set_superbass(int value)
+{
+ (void)value;
+}
+#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
+#endif /* SIMULATOR */
+
+void sound_set(int setting, int value)
+{
+ sound_set_type* sound_set_val = sound_get_fn(setting);
+ if (sound_set_val)
sound_set_val(value);
}
int sound_val2phys(int setting, int value)
{
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+#if CONFIG_CODEC == MAS3587F
int result = 0;
-
+
switch(setting)
{
case SOUND_LEFT_GAIN:
@@ -744,6 +663,7 @@ int sound_val2phys(int setting, int value)
}
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+#ifndef SIMULATOR
/* This function works by telling the decoder that we have another
crystal frequency than we actually have. It will adjust its internal
parameters and the result is that the audio is played at another pitch.
@@ -775,7 +695,7 @@ int sound_get_pitch(void)
{
return last_pitch;
}
-#elif defined SIMULATOR
+#else /* SIMULATOR */
void sound_set_pitch(int pitch)
{
(void)pitch;
@@ -785,5 +705,5 @@ int sound_get_pitch(void)
{
return 1000;
}
-#endif
-
+#endif /* SIMULATOR */
+#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */