summaryrefslogtreecommitdiffstats
path: root/firmware/sound.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-04-12 23:35:47 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-04-15 12:02:05 -0400
commit0c7b7873984e04941c9f21fa272638018fdb9a16 (patch)
treefb6afca45d2bef0a2c91732a39ffc0b965f5c557 /firmware/sound.c
parentfd9e2568908f91b5bcf7378dc28f6ec070d6027a (diff)
downloadrockbox-0c7b7873984e04941c9f21fa272638018fdb9a16.tar.gz
rockbox-0c7b7873984e04941c9f21fa272638018fdb9a16.zip
Straighten out the mad twisted state of sound.c and related areas.
This is going right in since it's long overdue. If anything is goofed, drop me a line or just tweak it yourself if you know what's wrong. :-) Make HW/SW codec interface more uniform when emulating HW functionality on SWCODEC for functions such as "audiohw_set_pitch". The firmware-to- DSP plumbing is in firmware/drivers/audiohw-swcodec.c. "sound_XXX" APIs are all in sound.c with none in DSP code any longer. Reduce number of settings definitions needed by each codec by providing defaults for common ones like balance, channels and SW tone controls. Remove need for separate SIM code and tables and add virtual codec header for hosted targets. Change-Id: I3f23702bca054fc9bda40f49824ce681bb7f777b
Diffstat (limited to 'firmware/sound.c')
-rw-r--r--firmware/sound.c489
1 files changed, 126 insertions, 363 deletions
diff --git a/firmware/sound.c b/firmware/sound.c
index 7c86b0bf05..4c390f4a5b 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -9,6 +9,7 @@
*
* Copyright (C) 2005 by Linus Nielsen Feltzing
* Copyright (C) 2007 by Christian Gmeiner
+ * Copyright (C) 2013 by Michael Sevakis
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -19,141 +20,95 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <stdbool.h>
-#include <stdio.h>
+ /* Indicate it's the sound.c file which affects compilation of audiohw.h */
+#define AUDIOHW_IS_SOUND_C
#include "config.h"
-#include "sound.h"
-#include "logf.h"
#include "system.h"
-#include "i2c.h"
+#include "sound.h"
+#include "fixedpoint.h"
#ifdef HAVE_SW_VOLUME_CONTROL
#include "pcm_sw_volume.h"
#endif /* HAVE_SW_VOLUME_CONTROL */
-/* TODO
- * find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble
-*/
+/* Define sound_setting_entries table */
+#define AUDIOHW_SOUND_SETTINGS_ENTRIES
+#include "audiohw_settings.h"
+
+/* Implements sound_val2phys */
+#define AUDIOHW_SOUND_SETTINGS_VAL2PHYS
+#include "audiohw_settings.h"
extern bool audio_is_initialized;
-const char *sound_unit(int setting)
+static const struct sound_setting_entry * get_setting_entry(int setting)
{
- return audiohw_settings[setting].unit;
+ static const struct sound_settings_info default_info =
+ { "", 0, 0, 0, 0, 0 };
+
+ static const struct sound_setting_entry default_entry =
+ { &default_info, NULL };
+
+ if ((unsigned)setting >= ARRAYLEN(sound_setting_entries))
+ return &default_entry;
+
+ const struct sound_setting_entry *e = &sound_setting_entries[setting];
+ return e->info ? e : &default_entry; /* setting valid but not in table? */
+}
+
+static const struct sound_settings_info * get_settings_info(int setting)
+{
+ return get_setting_entry(setting)->info;
+}
+
+const char * sound_unit(int setting)
+{
+ return get_settings_info(setting)->unit;
}
int sound_numdecimals(int setting)
{
- return audiohw_settings[setting].numdecimals;
+ return get_settings_info(setting)->numdecimals;
}
int sound_steps(int setting)
{
- return audiohw_settings[setting].steps;
+ return get_settings_info(setting)->steps;
}
int sound_min(int setting)
{
- return audiohw_settings[setting].minval;
+ return get_settings_info(setting)->minval;
}
int sound_max(int setting)
{
- return audiohw_settings[setting].maxval;
+ return get_settings_info(setting)->maxval;
}
int sound_default(int setting)
{
- return audiohw_settings[setting].defaultval;
+ return get_settings_info(setting)->defaultval;
}
-static sound_set_type * const sound_set_fns[] =
+sound_set_type * sound_get_fn(int setting)
{
- [0 ... SOUND_LAST_SETTING-1] = NULL,
- [SOUND_VOLUME] = sound_set_volume,
-#if defined(AUDIOHW_HAVE_BASS)
- [SOUND_BASS] = sound_set_bass,
-#endif
-#if defined(AUDIOHW_HAVE_TREBLE)
- [SOUND_TREBLE] = sound_set_treble,
-#endif
- [SOUND_BALANCE] = sound_set_balance,
- [SOUND_CHANNELS] = sound_set_channels,
- [SOUND_STEREO_WIDTH] = sound_set_stereo_width,
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- [SOUND_LOUDNESS] = sound_set_loudness,
- [SOUND_AVC] = sound_set_avc,
- [SOUND_MDB_STRENGTH] = sound_set_mdb_strength,
- [SOUND_MDB_HARMONICS] = sound_set_mdb_harmonics,
- [SOUND_MDB_CENTER] = sound_set_mdb_center,
- [SOUND_MDB_SHAPE] = sound_set_mdb_shape,
- [SOUND_MDB_ENABLE] = sound_set_mdb_enable,
- [SOUND_SUPERBASS] = sound_set_superbass,
-#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
-#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
- [SOUND_BASS_CUTOFF] = sound_set_bass_cutoff,
-#endif
-#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
- [SOUND_TREBLE_CUTOFF] = sound_set_treble_cutoff,
-#endif
-#if defined(AUDIOHW_HAVE_DEPTH_3D)
- [SOUND_DEPTH_3D] = sound_set_depth_3d,
-#endif
-/* Hardware EQ tone controls */
-#if defined(AUDIOHW_HAVE_EQ)
- [SOUND_EQ_BAND1_GAIN] = sound_set_hw_eq_band1_gain,
-#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
- [SOUND_EQ_BAND1_FREQUENCY] = sound_set_hw_eq_band1_frequency,
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND2)
- [SOUND_EQ_BAND2_GAIN] = sound_set_hw_eq_band2_gain,
-#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
- [SOUND_EQ_BAND2_FREQUENCY] = sound_set_hw_eq_band2_frequency,
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
- [SOUND_EQ_BAND2_WIDTH] = sound_set_hw_eq_band2_width,
-#endif
-#endif /* AUDIOHW_HAVE_EQ_BAND2 */
-#if defined(AUDIOHW_HAVE_EQ_BAND3)
- [SOUND_EQ_BAND3_GAIN] = sound_set_hw_eq_band3_gain,
-#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
- [SOUND_EQ_BAND3_FREQUENCY] = sound_set_hw_eq_band3_frequency,
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
- [SOUND_EQ_BAND3_WIDTH] = sound_set_hw_eq_band3_width,
-#endif
-#endif /* AUDIOHW_HAVE_EQ_BAND3 */
-#if defined(AUDIOHW_HAVE_EQ_BAND4)
- [SOUND_EQ_BAND4_GAIN] = sound_set_hw_eq_band4_gain,
-#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
- [SOUND_EQ_BAND4_FREQUENCY] = sound_set_hw_eq_band4_frequency,
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
- [SOUND_EQ_BAND4_WIDTH] = sound_set_hw_eq_band4_width,
-#endif
-#endif /* AUDIOHW_HAVE_EQ_BAND4 */
-#if defined(AUDIOHW_HAVE_EQ_BAND5)
- [SOUND_EQ_BAND5_GAIN] = sound_set_hw_eq_band5_gain,
-#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
- [SOUND_EQ_BAND5_FREQUENCY] = sound_set_hw_eq_band5_frequency,
-#endif
-#endif /* AUDIOHW_HAVE_EQ_BAND5 */
-#endif /* AUDIOHW_HAVE_EQ */
-};
+ return get_setting_entry(setting)->function;
+}
-sound_set_type* sound_get_fn(int setting)
+void sound_set(int setting, int value)
{
- return ((unsigned)setting >= ARRAYLEN(sound_set_fns)?
- NULL : sound_set_fns[setting]);
-}
+ sound_set_type *sound_set_val = sound_get_fn(setting);
-#if CONFIG_CODEC == SWCODEC
-static int (*dsp_callback)(int, intptr_t) = NULL;
+ if (sound_set_val)
+ sound_set_val(value);
+}
-void sound_set_dsp_callback(int (*func)(int, intptr_t))
+/* Return the sound value scaled to centibels (tenth-decibels) */
+static int sound_value_to_cb(int setting, int value)
{
- dsp_callback = func;
+ long e = (1 - sound_numdecimals(setting)) << 16;
+ return fp_mul(value, fp_exp10(e, 16), 16);
}
-#endif
#if !defined(AUDIOHW_HAVE_CLIPPING)
/*
@@ -165,39 +120,31 @@ void sound_set_dsp_callback(int (*func)(int, intptr_t))
* by 12 dB after processing.
*/
-/* all values in tenth of dB MAS3507D UDA1380 */
-static int current_volume = 0; /* -780..+180 -840.. 0 */
-static int current_balance = 0; /* -960..+960 -840..+840 */
+static int current_volume = 0; /* tenth dB */
+static int current_balance = 0; /* percent */
#ifdef AUDIOHW_HAVE_TREBLE
-static int current_treble = 0; /* -150..+150 0.. +60 */
+static int current_treble = 0; /* tenth dB */
#endif
#ifdef AUDIOHW_HAVE_BASS
-static int current_bass = 0; /* -150..+150 0..+240 */
+static int current_bass = 0; /* tenth dB */
#endif
#ifdef AUDIOHW_HAVE_EQ
-static int current_eq_band_gain[AUDIOHW_EQ_BAND_NUM];
+static int current_eq_band_gain[AUDIOHW_EQ_BAND_NUM]; /* tenth dB */
#endif
static void set_prescaled_volume(void)
{
int prescale = 0;
- int l, r;
-/* The codecs listed use HW tone controls but don't have suitable prescaler
- * functionality, so we let the prescaler stay at 0 for these, unless
- * SW tone controls are in use. This is to avoid needing the SW DSP just for
- * the prescaling.
- */
-#if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \
- || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
- || defined(HAVE_WM8758) || defined(HAVE_WM8985) || defined(HAVE_UDA1341))
+#if defined(AUDIOHW_HAVE_BASS) || defined(AUDIOHW_HAVE_TREBLE) \
+ || defined(AUDIOHW_HAVE_EQ)
+ /* Note: Having Tone + EQ isn't prohibited */
#if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
prescale = MAX(current_bass, current_treble);
#endif
#if defined(AUDIOHW_HAVE_EQ)
- int i;
- for (i = 0; i < AUDIOHW_EQ_BAND_NUM; i++)
+ for (int i = 0; i < AUDIOHW_EQ_BAND_NUM; i++)
prescale = MAX(current_eq_band_gain[i], prescale);
#endif
@@ -210,86 +157,65 @@ static void set_prescaled_volume(void)
* instead (might cause clipping). */
if (current_volume + prescale > VOLUME_MAX)
prescale = VOLUME_MAX - current_volume;
-#endif
-#if defined(AUDIOHW_HAVE_PRESCALER)
audiohw_set_prescaler(prescale);
-#else
- dsp_callback(DSP_CALLBACK_SET_PRESCALE, prescale);
-#endif
- if (current_volume <= VOLUME_MIN)
- prescale = 0; /* Make sure the chip gets muted at VOLUME_MIN */
+ if (current_volume < VOLUME_MIN)
+ prescale = 0; /* Make sure the audio gets muted */
+#endif /* AUDIOHW_HAVE_BASS || AUDIOHW_HAVE_TREBLE || AUDIOHW_HAVE_EQ */
- l = r = current_volume + prescale;
+#if defined(AUDIOHW_HAVE_MONO_VOLUME)
+ audiohw_set_volume(current_volume);
+#else /* Stereo volume */
+ int l = current_volume + prescale, r = l;
/* Balance the channels scaled by the current volume and min volume. */
/* Subtract a dB from VOLUME_MIN to get it to a mute level */
- if (current_balance > 0)
+ int volshift = current_balance * VOLUME_RANGE / 100; /* tenth of dB */
+
+ if (volshift > 0)
{
- l -= ((l - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
+ l -= ((l - (VOLUME_MIN - ONE_DB)) * volshift) / VOLUME_RANGE;
}
- else if (current_balance < 0)
+ else if (volshift < 0)
{
- r += ((r - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
+ r += ((r - (VOLUME_MIN - ONE_DB)) * volshift) / VOLUME_RANGE;
}
-/* ypr0 with sdl has separate volume controls */
-#if defined(HAVE_SW_VOLUME_CONTROL)
- audiohw_set_master_vol(l, r);
-#elif !defined(HAVE_SDL_AUDIO) || defined(SAMSUNG_YPR0)
-#if defined(HAVE_JZ4740_CODEC)
- audiohw_set_master_vol(l, r);
-#elif CONFIG_CODEC == MAS3507D
- dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
-#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
- || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
- || defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_AS3514) \
- || defined(HAVE_TSC2100) || defined(HAVE_AK4537) || defined(HAVE_UDA1341) \
- || defined(HAVE_CS42L55) || defined(HAVE_RK27XX_CODEC)
- audiohw_set_master_vol(tenthdb2master(l), tenthdb2master(r));
-#if defined(HAVE_WM8975) || defined(HAVE_WM8758) \
- || (defined(HAVE_WM8751) && defined(TOSHIBA_GIGABEAT_F)) \
- || defined(HAVE_WM8985) || defined(HAVE_CS42L55)
- audiohw_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
-#endif
+ audiohw_set_volume(l, r);
+#endif /* AUDIOHW_HAVE_MONO_VOLUME */
-#elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985) || defined(HAVE_IMX233_CODEC) || defined(HAVE_AIC3X)
- audiohw_set_headphone_vol(tenthdb2master(l), tenthdb2master(r));
-#elif defined(HAVE_SDL_AUDIO) || defined(ANDROID)
- audiohw_set_volume(current_volume);
-#endif
-#else /* HAVE_SDL_AUDIO */
- audiohw_set_volume(current_volume);
-#endif /* !HAVE_SDL_AUDIO */
+#if defined(AUDIOHW_HAVE_LINEOUT)
+ /* For now, lineout stays at unity */
+ audiohw_set_lineout_volume(0, 0);
+#endif /* AUDIOHW_HAVE_LINEOUT */
+
+ (void)prescale; /* In case of no tone controls + mono volume */
}
-#endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */
+#endif /* AUDIOIHW_HAVE_CLIPPING */
void sound_set_volume(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
#if defined(AUDIOHW_HAVE_CLIPPING)
audiohw_set_volume(value);
-#elif CONFIG_CPU == PNX0101
- int tmp = (60 - value * 4) & 0xff;
- CODECVOL = tmp | (tmp << 8);
#else
- current_volume = value * 10; /* tenth of dB */
+ current_volume = sound_value_to_cb(SOUND_VOLUME, value);
set_prescaled_volume();
#endif
}
void sound_set_balance(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
-#ifdef AUDIOHW_HAVE_BALANCE
+#if defined(AUDIOHW_HAVE_BALANCE)
audiohw_set_balance(value);
#else
- current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
+ current_balance = value;
set_prescaled_volume();
#endif
}
@@ -297,24 +223,13 @@ void sound_set_balance(int value)
#ifdef AUDIOHW_HAVE_BASS
void sound_set_bass(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
-#if !defined(AUDIOHW_HAVE_CLIPPING)
-#if defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_CS42L55)
- current_bass = value;
-#else
- current_bass = value * 10;
-#endif
-#endif
-
-#if defined(HAVE_SW_TONE_CONTROLS)
- dsp_callback(DSP_CALLBACK_SET_BASS, current_bass);
-#else
audiohw_set_bass(value);
-#endif
#if !defined(AUDIOHW_HAVE_CLIPPING)
+ current_bass = sound_value_to_cb(SOUND_BASS, value);
set_prescaled_volume();
#endif
}
@@ -323,24 +238,13 @@ void sound_set_bass(int value)
#ifdef AUDIOHW_HAVE_TREBLE
void sound_set_treble(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
-#if !defined(AUDIOHW_HAVE_CLIPPING)
-#if defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_CS42L55)
- current_treble = value;
-#else
- current_treble = value * 10;
-#endif
-#endif
-
-#if defined(HAVE_SW_TONE_CONTROLS)
- dsp_callback(DSP_CALLBACK_SET_TREBLE, current_treble);
-#else
audiohw_set_treble(value);
-#endif
#if !defined(AUDIOHW_HAVE_CLIPPING)
+ current_treble = sound_value_to_cb(SOUND_TREBLE, value);
set_prescaled_volume();
#endif
}
@@ -349,7 +253,7 @@ void sound_set_treble(int value)
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
void sound_set_bass_cutoff(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_bass_cutoff(value);
@@ -359,7 +263,7 @@ void sound_set_bass_cutoff(int value)
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
void sound_set_treble_cutoff(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_treble_cutoff(value);
@@ -368,32 +272,24 @@ void sound_set_treble_cutoff(int value)
void sound_set_channels(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
-#if CONFIG_CODEC == SWCODEC
- dsp_callback(DSP_CALLBACK_SET_CHANNEL_CONFIG, value);
-#else
audiohw_set_channel(value);
-#endif
}
void sound_set_stereo_width(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
-#if CONFIG_CODEC == SWCODEC
- dsp_callback(DSP_CALLBACK_SET_STEREO_WIDTH, value);
-#else
audiohw_set_stereo_width(value);
-#endif
}
#if defined(AUDIOHW_HAVE_DEPTH_3D)
void sound_set_depth_3d(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_depth_3d(value);
@@ -470,13 +366,11 @@ int sound_enum_hw_eq_band_setting(unsigned int band,
static void sound_set_hw_eq_band_gain(unsigned int band, int value)
{
- int setting;
-
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
- setting = sound_enum_hw_eq_band_setting(band, AUDIOHW_EQ_GAIN);
- current_eq_band_gain[band] = sound_val2phys(setting + 0x10000, value);
+ int setting = sound_enum_hw_eq_band_setting(band, AUDIOHW_EQ_GAIN);
+ current_eq_band_gain[band] = sound_value_to_cb(setting, value);
audiohw_set_eq_band_gain(band, value);
set_prescaled_volume();
@@ -518,7 +412,7 @@ void sound_set_hw_eq_band5_gain(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
void sound_set_hw_eq_band1_frequency(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND1, value);
@@ -528,7 +422,7 @@ void sound_set_hw_eq_band1_frequency(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
void sound_set_hw_eq_band2_frequency(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND2, value);
@@ -538,7 +432,7 @@ void sound_set_hw_eq_band2_frequency(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
void sound_set_hw_eq_band3_frequency(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND3, value);
@@ -548,7 +442,7 @@ void sound_set_hw_eq_band3_frequency(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
void sound_set_hw_eq_band4_frequency(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND4, value);
@@ -558,7 +452,7 @@ void sound_set_hw_eq_band4_frequency(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
void sound_set_hw_eq_band5_frequency(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_frequency(AUDIOHW_EQ_BAND5, value);
@@ -568,7 +462,7 @@ void sound_set_hw_eq_band5_frequency(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
void sound_set_hw_eq_band2_width(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_width(AUDIOHW_EQ_BAND2, value);
@@ -578,7 +472,7 @@ void sound_set_hw_eq_band2_width(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
void sound_set_hw_eq_band3_width(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_width(AUDIOHW_EQ_BAND3, value);
@@ -588,7 +482,7 @@ void sound_set_hw_eq_band3_width(int value)
#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
void sound_set_hw_eq_band4_width(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_eq_band_width(AUDIOHW_EQ_BAND4, value);
@@ -596,10 +490,10 @@ void sound_set_hw_eq_band4_width(int value)
#endif
#endif /* AUDIOHW_HAVE_EQ */
-#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F))
+#if CONFIG_CODEC == MAS3587F || CONFIG_CODEC == MAS3539F
void sound_set_loudness(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_loudness(value);
@@ -607,7 +501,7 @@ void sound_set_loudness(int value)
void sound_set_avc(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_avc(value);
@@ -615,7 +509,7 @@ void sound_set_avc(int value)
void sound_set_mdb_strength(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_mdb_strength(value);
@@ -623,7 +517,7 @@ void sound_set_mdb_strength(int value)
void sound_set_mdb_harmonics(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_mdb_harmonics(value);
@@ -631,7 +525,7 @@ void sound_set_mdb_harmonics(int value)
void sound_set_mdb_center(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_mdb_center(value);
@@ -639,7 +533,7 @@ void sound_set_mdb_center(int value)
void sound_set_mdb_shape(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_mdb_shape(value);
@@ -647,7 +541,7 @@ void sound_set_mdb_shape(int value)
void sound_set_mdb_enable(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_mdb_enable(value);
@@ -655,158 +549,27 @@ void sound_set_mdb_enable(int value)
void sound_set_superbass(int value)
{
- if(!audio_is_initialized)
+ if (!audio_is_initialized)
return;
audiohw_set_superbass(value);
}
-#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
-
-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);
-}
-
-#if (!defined(HAVE_AS3514) && !defined(HAVE_WM8975) \
- && !defined(HAVE_WM8758) && !defined(HAVE_TSC2100) \
- && !defined (HAVE_WM8711) && !defined (HAVE_WM8721) \
- && !defined (HAVE_WM8731) && !defined (HAVE_WM8978) \
- && !defined (HAVE_WM8750) && !defined (HAVE_WM8751) \
- && !defined(HAVE_AK4537)) || defined(SIMULATOR)
-int sound_val2phys(int setting, int value)
-{
-#if CONFIG_CODEC == MAS3587F
- int result = 0;
-
- switch(setting)
- {
- case SOUND_LEFT_GAIN:
- case SOUND_RIGHT_GAIN:
- result = (value - 2) * 15;
- break;
-
- case SOUND_MIC_GAIN:
- result = value * 15 + 210;
- break;
-
- default:
- result = value;
- break;
- }
- return result;
-#elif defined(HAVE_UDA1380)
- int result = 0;
-
- switch(setting)
- {
-#ifdef HAVE_RECORDING
- case SOUND_LEFT_GAIN:
- case SOUND_RIGHT_GAIN:
- case SOUND_MIC_GAIN:
- result = value * 5; /* (1/2) * 10 */
- break;
-#endif
- default:
- result = value;
- break;
- }
- return result;
-#elif defined(HAVE_TLV320) || defined(HAVE_WM8711) \
- || defined(HAVE_WM8721) || defined(HAVE_WM8731)
- int result = 0;
-
- switch(setting)
- {
-#ifdef HAVE_RECORDING
- case SOUND_LEFT_GAIN:
- case SOUND_RIGHT_GAIN:
- result = (value - 23) * 15; /* (x - 23)/1.5 *10 */
- break;
-
- case SOUND_MIC_GAIN:
- result = value * 200; /* 0 or 20 dB */
- break;
-#endif
- default:
- result = value;
- break;
- }
- return result;
-#elif defined(HAVE_AS3514)
- /* This is here for the sim only and the audio driver has its own */
- int result;
-
- switch(setting)
- {
-#ifdef HAVE_RECORDING
- case SOUND_LEFT_GAIN:
- case SOUND_RIGHT_GAIN:
- case SOUND_MIC_GAIN:
- result = (value - 23) * 15;
- break;
-#endif
- default:
- result = value;
- break;
- }
-
- return result;
-#elif defined(HAVE_WM8978) || defined(HAVE_WM8750) || defined(HAVE_WM8751)
- int result;
-
- switch (setting)
- {
-#ifdef HAVE_RECORDING
- case SOUND_LEFT_GAIN:
- case SOUND_RIGHT_GAIN:
- case SOUND_MIC_GAIN:
- result = value * 5;
- break;
-#endif
-#ifdef AUDIOHW_HAVE_DEPTH_3D
- case SOUND_DEPTH_3D:
- result = (100 * value + 8) / 15;
- break;
-#endif
- default:
- result = value;
- }
-
- return result;
-#else
- (void)setting;
- return value;
-#endif
-}
-#endif /* CONFIG_CODECs || PLATFORM_HOSTED */
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
-/* 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.
-*/
-
-static int last_pitch = PITCH_SPEED_100;
+#endif /* CONFIG_CODEC == MAS3587F || CONFIG_CODEC == MAS3539F */
+#ifdef HAVE_PITCHCONTROL
void sound_set_pitch(int32_t pitch)
{
- unsigned long val;
-
- if (pitch != last_pitch)
- {
- /* Calculate the new (bogus) frequency */
- val = 18432 * PITCH_SPEED_100 / pitch;
-
- audiohw_set_pitch(val);
+ if (!audio_is_initialized)
+ return;
- last_pitch = pitch;
- }
+ audiohw_set_pitch(pitch);
}
int32_t sound_get_pitch(void)
{
- return last_pitch;
+ if (!audio_is_initialized)
+ return PITCH_SPEED_100;
+
+ return audiohw_get_pitch();
}
-#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
+#endif /* HAVE_PITCHCONTROL */