summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-03-07 19:11:16 +0000
committerThom Johansen <thomj@rockbox.org>2007-03-07 19:11:16 +0000
commit99b2742cd0de7181677f3aa7222caa5dc358ee12 (patch)
tree55c0cec293ca3fb1c35dc5fa983bb03bff54785d
parent09b97b4a21921f05d29d215e0d5cf7df4f83a472 (diff)
downloadrockbox-99b2742cd0de7181677f3aa7222caa5dc358ee12.tar.gz
rockbox-99b2742cd0de7181677f3aa7222caa5dc358ee12.zip
Use the new DSP callback functionality in firmware/sound.c to deal with SWCODEC stereo width and channel configuration instead of the old more spread out #ifdef based approach. Rename the DSP functions involved for more consistent naming.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12677 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/dsp.c15
-rw-r--r--apps/dsp.h8
-rw-r--r--apps/settings.c16
-rw-r--r--apps/settings_list.c4
-rw-r--r--firmware/sound.c10
5 files changed, 26 insertions, 27 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 9e410f879a..be851e2305 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -971,7 +971,7 @@ static void apply_gain(int count, int32_t *buf[])
FRACMUL_8_LOOP(s, gain, sl, d);
}
-void stereo_width_set(int value)
+void dsp_set_stereo_width(int value)
{
long width, straight, cross;
@@ -1022,6 +1022,8 @@ static void channels_process_sound_chan_mono(int count, int32_t *buf[])
}
#endif /* DSP_HAVE_ASM_SOUND_CHAN_MONO */
+#if CONFIG_CODEC == SWCODEC
+
#ifdef HAVE_SW_TONE_CONTROLS
static void set_tone_controls(void)
{
@@ -1029,10 +1031,12 @@ static void set_tone_controls(void)
0xffffffff/NATIVE_FREQUENCY*3500,
bass, treble, -prescale, tone_filter.coefs);
}
+#endif
int dsp_callback(int msg, intptr_t param)
{
switch (msg) {
+#ifdef HAVE_SW_TONE_CONTROLS
case DSP_CALLBACK_SET_PRESCALE:
prescale = param;
set_tone_controls();
@@ -1045,6 +1049,13 @@ int dsp_callback(int msg, intptr_t param)
break;
case DSP_CALLBACK_SET_TREBLE:
treble = param;
+#endif
+ case DSP_CALLBACK_SET_CHANNEL_CONFIG:
+ dsp_set_channel_config(param);
+ break;
+ case DSP_CALLBACK_SET_STEREO_WIDTH:
+ dsp_set_stereo_width(param);
+ break;
default:
break;
}
@@ -1097,7 +1108,7 @@ static void channels_process_sound_chan_karaoke(int count, int32_t *buf[])
}
#endif /* DSP_HAVE_ASM_SOUND_CHAN_KARAOKE */
-void channels_set(int value)
+void dsp_set_channel_config(int value)
{
static const channels_process_fn_type channels_process_functions[] =
{
diff --git a/apps/dsp.h b/apps/dsp.h
index 03118e8c31..5d6e964d89 100644
--- a/apps/dsp.h
+++ b/apps/dsp.h
@@ -54,7 +54,9 @@ enum
enum {
DSP_CALLBACK_SET_PRESCALE = 0,
DSP_CALLBACK_SET_BASS,
- DSP_CALLBACK_SET_TREBLE
+ DSP_CALLBACK_SET_TREBLE,
+ DSP_CALLBACK_SET_CHANNEL_CONFIG,
+ DSP_CALLBACK_SET_STEREO_WIDTH
};
/* A bunch of fixed point assembler helper macros */
@@ -216,8 +218,8 @@ void dsp_set_eq_coefs(int band);
void sound_set_pitch(int r);
int sound_get_pitch(void);
int dsp_callback(int msg, intptr_t param);
-void channels_set(int value);
-void stereo_width_set(int value);
+void dsp_set_channel_config(int value);
+void dsp_set_stereo_width(int value);
void dsp_dither_enable(bool enable);
#endif
diff --git a/apps/settings.c b/apps/settings.c
index 331229190a..0b2f2d9d40 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -642,20 +642,15 @@ void settings_apply_pm_range(void)
void sound_settings_apply(void)
{
-#ifdef HAVE_SW_TONE_CONTROLS
+#if CONFIG_CODEC == SWCODEC
sound_set_dsp_callback(dsp_callback);
#endif
sound_set(SOUND_BASS, global_settings.bass);
sound_set(SOUND_TREBLE, global_settings.treble);
sound_set(SOUND_BALANCE, global_settings.balance);
sound_set(SOUND_VOLUME, global_settings.volume);
-#if CONFIG_CODEC == SWCODEC
- channels_set(global_settings.channel_config);
- stereo_width_set(global_settings.stereo_width);
-#else
sound_set(SOUND_CHANNELS, global_settings.channel_config);
sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width);
-#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
sound_set(SOUND_LOUDNESS, global_settings.loudness);
sound_set(SOUND_AVC, global_settings.avc);
@@ -952,6 +947,7 @@ static void dec_sound_formatter(char *buffer, int buffer_size,
int dec = val % 10;
snprintf(buffer, buffer_size, "%c%d.%d %s", sign, integer, dec, unit);
}
+
bool set_sound(const unsigned char * string,
int* variable,
int setting)
@@ -970,14 +966,6 @@ bool set_sound(const unsigned char * string,
else if (*unit == 'H')
talkunit = UNIT_HERTZ;
if (!numdec)
-#if CONFIG_CODEC == SWCODEC
- /* We need to hijack this one and send it off to apps/dsp.c instead of
- firmware/sound.c */
- if (setting == SOUND_STEREO_WIDTH)
- return set_int(string, unit, talkunit, variable, &stereo_width_set,
- steps, min, max, NULL );
- else
-#endif
return set_int(string, unit, talkunit, variable, sound_callback,
steps, min, max, NULL );
else
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 6594db7aa3..e8ee59790d 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -352,11 +352,7 @@ const struct settings_list settings[] = {
CHOICE_SETTING(0,channel_config,LANG_CHANNEL,0,"channels",
"stereo,mono,custom,mono left,mono right,karaoke",
-#if CONFIG_CODEC == SWCODEC
- channels_set,
-#else
sound_set_channels,
-#endif
6, ID2P(LANG_CHANNEL_STEREO), ID2P(LANG_CHANNEL_MONO),
ID2P(LANG_CHANNEL_CUSTOM), ID2P(LANG_CHANNEL_LEFT),
ID2P(LANG_CHANNEL_RIGHT), ID2P(LANG_CHANNEL_KARAOKE)),
diff --git a/firmware/sound.c b/firmware/sound.c
index 6182e6b567..7b29e1f13f 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -169,12 +169,14 @@ sound_set_type* sound_get_fn(int setting)
return NULL;
}
-#ifdef HAVE_SW_TONE_CONTROLS
+#if CONFIG_CODEC == SWCODEC
/* Copied from dsp.h, nasty nasty, but we don't want to include dsp.h */
enum {
DSP_CALLBACK_SET_PRESCALE = 0,
DSP_CALLBACK_SET_BASS,
- DSP_CALLBACK_SET_TREBLE
+ DSP_CALLBACK_SET_TREBLE,
+ DSP_CALLBACK_SET_CHANNEL_CONFIG,
+ DSP_CALLBACK_SET_STEREO_WIDTH
};
static int (*dsp_callback)(int, intptr_t) = NULL;
@@ -567,7 +569,7 @@ void sound_set_treble(int value)
void sound_set_channels(int value)
{
#if CONFIG_CODEC == SWCODEC
- (void)value;
+ dsp_callback(DSP_CALLBACK_SET_CHANNEL_CONFIG, value);
#else
if(!audio_is_initialized)
return;
@@ -579,7 +581,7 @@ void sound_set_channels(int value)
void sound_set_stereo_width(int value)
{
#if CONFIG_CODEC == SWCODEC
- (void)value;
+ dsp_callback(DSP_CALLBACK_SET_STEREO_WIDTH, value);
#else
if(!audio_is_initialized)
return;