summaryrefslogtreecommitdiff
path: root/firmware/sound.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-07-25 00:48:40 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-07-25 00:48:40 -0500
commit5f9d1f59d308e5832432d6f3d4e7380ef656521b (patch)
tree30ceec1aea278524893f7a20808f856eaa3f76bd /firmware/sound.c
parent7e4902bf6bfcf0acef0889bf4e3fae04a8839079 (diff)
Add sound_current to plugin api
Adds: sound_current(int setting) returns the current sound setting from global_settings complements sound_max, sound_min and sound_default Change-Id: I35bd893753c958f808492906fe533edc51d5d57c
Diffstat (limited to 'firmware/sound.c')
-rw-r--r--firmware/sound.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/firmware/sound.c b/firmware/sound.c
index a19cc15c41..9db30524d6 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -25,6 +25,8 @@
#include "config.h"
#include "system.h"
#include "sound.h"
+#include "settings.h" /* sound_current */
+
#ifdef HAVE_SW_VOLUME_CONTROL
#include "pcm_sw_volume.h"
#endif /* HAVE_SW_VOLUME_CONTROL */
@@ -37,6 +39,10 @@
#define AUDIOHW_SOUND_SETTINGS_VAL2PHYS
#include "audiohw_settings.h"
+/* Returns current sound settings from global_settings */
+#define SOUND_CUR_SET(name, var) \
+ case SOUND_##name: return var;
+
extern bool audio_is_initialized;
static const struct sound_setting_entry * get_setting_entry(int setting)
@@ -102,6 +108,89 @@ void sound_set(int setting, int value)
sound_set_val(value);
}
+int sound_current(int setting)
+{
+ switch(setting)
+ {
+#ifndef PLATFORM_HAS_VOLUME_CHANGE
+ SOUND_CUR_SET(VOLUME, global_settings.volume)
+#endif
+#if defined(AUDIOHW_HAVE_BASS)
+ SOUND_CUR_SET(BASS, global_settings.bass)
+#endif
+#if defined(AUDIOHW_HAVE_TREBLE)
+ SOUND_CUR_SET(TREBLE, global_settings.treble)
+#endif
+ SOUND_CUR_SET(BALANCE, global_settings.balance)
+ SOUND_CUR_SET(CHANNELS, global_settings.channel_config)
+ SOUND_CUR_SET(STEREO_WIDTH, global_settings.stereo_width)
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+ SOUND_CUR_SET(LOUDNESS, global_settings.loudness)
+ SOUND_CUR_SET(AVC, global_settings.avc)
+ SOUND_CUR_SET(MDB_STRENGTH, global_settings.mdb_strength)
+ SOUND_CUR_SET(MDB_HARMONICS, global_settings.mdb_harmonics)
+ SOUND_CUR_SET(MDB_CENTER, global_settings.mdb_center)
+ SOUND_CUR_SET(MDB_SHAPE, global_settings.mdb_shape)
+ SOUND_CUR_SET(MDB_ENABLE, global_settings.mdb_enable)
+ SOUND_CUR_SET(SUPERBASS, global_settings.superbass)
+#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
+#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
+ SOUND_CUR_SET(BASS_CUTOFF, global_settings.bass_cutoff)
+#endif
+#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
+ SOUND_CUR_SET(TREBLE_CUTOFF, global_settings.treble_cutoff)
+#endif
+#if defined(AUDIOHW_HAVE_DEPTH_3D)
+ SOUND_CUR_SET(DEPTH_3D, global_settings.depth_3d)
+#endif
+#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF)
+ SOUND_CUR_SET(FILTER_ROLL_OFF, global_settings.filter_roll_off)
+#endif
+/* Hardware EQ tone controls */
+#if defined(AUDIOHW_HAVE_EQ)
+ SOUND_CUR_SET(EQ_BAND1_GAIN, global_settings.hw_eq_band1_gain)
+#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
+ SOUND_CUR_SET(EQ_BAND1_FREQUENCY, global_settings.hw_eq_band1_frequency)
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND2)
+ SOUND_CUR_SET(EQ_BAND2_GAIN, global_settings.hw_eq_band2_gain)
+#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
+ SOUND_CUR_SET(EQ_BAND2_FREQUENCY, global_settings.hw_eq_band2_frequency)
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
+ SOUND_CUR_SET(EQ_BAND2_WIDTH, global_settings.hw_eq_band2_width)
+#endif
+#endif /* AUDIOHW_HAVE_EQ_BAND2 */
+#if defined(AUDIOHW_HAVE_EQ_BAND3)
+ SOUND_CUR_SET(EQ_BAND3_GAIN, global_settings.hw_eq_band3_gain)
+#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
+ SOUND_CUR_SET(EQ_BAND3_FREQUENCY, global_settings.hw_eq_band3_frequency)
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
+ SOUND_CUR_SET(EQ_BAND3_WIDTH, global_settings.hw_eq_band3_width)
+#endif
+#endif /* AUDIOHW_HAVE_EQ_BAND3 */
+#if defined(AUDIOHW_HAVE_EQ_BAND4)
+ SOUND_CUR_SET(EQ_BAND4_GAIN, global_settings.hw_eq_band4_gain)
+#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
+ SOUND_CUR_SET(EQ_BAND4_FREQUENCY, global_settings.hw_eq_band4_frequency)
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
+ SOUND_CUR_SET(EQ_BAND4_WIDTH, global_settings.hw_eq_band4_width)
+#endif
+#endif /* AUDIOHW_HAVE_EQ_BAND4 */
+#if defined(AUDIOHW_HAVE_EQ_BAND5)
+ SOUND_CUR_SET(EQ_BAND5_GAIN, global_settings.hw_eq_band5_gain)
+#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
+ SOUND_CUR_SET(EQ_BAND5_FREQUENCY, global_settings.hw_eq_band5_frequency)
+#endif
+#endif /* AUDIOHW_HAVE_EQ_BAND5 */
+#endif /* AUDIOHW_HAVE_EQ */
+ default:
+ return INT_MIN;
+ } /* switch(setting) */
+}/* sound_current */
+
#if !defined(AUDIOHW_HAVE_CLIPPING)
/*
* The prescaler compensates for any kind of boosts, to prevent clipping.