summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-03-13 02:11:45 +0000
committerSolomon Peachy <pizza@shaftnet.org>2021-03-22 13:00:11 +0000
commit55805e13a4ef0152b40e6606fce8b4603ae8cb91 (patch)
tree34171877486e5732233439ef1058007cad36ed29 /firmware
parent3a254a92c7363aad95cfcc549732e44d9eddc42b (diff)
downloadrockbox-55805e13a4ef0152b40e6606fce8b4603ae8cb91.tar.gz
rockbox-55805e13a4ef0152b40e6606fce8b4603ae8cb91.tar.bz2
rockbox-55805e13a4ef0152b40e6606fce8b4603ae8cb91.zip
Add new audiohw capability: POWER_MODE_CAP
This allows the user to make use of the DAC's power-saving abilities. The two modes are "high performance" and "battery saver". This feature is supported by the AK4376 DAC in the upcoming FiiO M3K port. The setting is only a manual toggle right now, but in the future it could be hooked up to the battery level (via another setting) so it can be toggled automatically when the battery gets too low. Change-Id: I482af6e2f969fcbdeb3411bd3ff91f866b12d027
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/audio/sdl.c4
-rw-r--r--firmware/export/audiohw.h15
-rw-r--r--firmware/export/audiohw_settings.h3
-rw-r--r--firmware/export/sound.h4
-rw-r--r--firmware/sound.c13
5 files changed, 39 insertions, 0 deletions
diff --git a/firmware/drivers/audio/sdl.c b/firmware/drivers/audio/sdl.c
index fb49a291d1..89f40baedf 100644
--- a/firmware/drivers/audio/sdl.c
+++ b/firmware/drivers/audio/sdl.c
@@ -118,6 +118,10 @@ void audiohw_set_lineout_volume(int vol_l, int vol_r)
void audiohw_set_filter_roll_off(int value)
{ (void)value; }
#endif
+#if defined(AUDIOHW_HAVE_POWER_MODE)
+void audiohw_set_power_mode(int value)
+ { (void)value; }
+#endif
void audiohw_close(void) {}
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index 8a46cbea78..d862c977db 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -41,6 +41,7 @@
#define LIN_GAIN_CAP (1 << 11)
#define MIC_GAIN_CAP (1 << 12)
#define FILTER_ROLL_OFF_CAP (1 << 13)
+#define POWER_MODE_CAP (1 << 14)
/* Used by every driver to export its min/max/default values for its audio
settings. */
@@ -391,6 +392,10 @@ enum AUDIOHW_EQ_SETTINGS
#define AUDIOHW_HAVE_FILTER_ROLL_OFF
#endif
+#if (AUDIOHW_CAPS & POWER_MODE_CAP)
+#define AUDIOHW_HAVE_POWER_MODE
+#endif
+
#endif /* AUDIOHW_CAPS */
#ifdef HAVE_SW_TONE_CONTROLS
@@ -586,6 +591,16 @@ void audiohw_set_depth_3d(int val);
void audiohw_set_filter_roll_off(int val);
#endif
+#ifdef AUDIOHW_HAVE_POWER_MODE
+/**
+ * Set DAC's power saving mode.
+ * @param enable 0 - highest performance, 1 - battery saving
+ * NOTE: AUDIOHW_CAPS need to contain
+ * POWER_MODE_CAP
+ */
+void audiohw_set_power_mode(int mode);
+#endif
+
void audiohw_set_frequency(int fsel);
#ifdef HAVE_RECORDING
diff --git a/firmware/export/audiohw_settings.h b/firmware/export/audiohw_settings.h
index 1d3e0dc12f..8010963ea4 100644
--- a/firmware/export/audiohw_settings.h
+++ b/firmware/export/audiohw_settings.h
@@ -103,6 +103,9 @@ AUDIOHW_SETTINGS(
#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF)
AUDIOHW_SETTING_ENT(FILTER_ROLL_OFF, sound_set_filter_roll_off)
#endif
+#if defined(AUDIOHW_HAVE_POWER_MODE)
+ AUDIOHW_SETTING_ENT(POWER_MODE, sound_set_power_mode)
+#endif
/* Hardware EQ tone controls */
#if defined(AUDIOHW_HAVE_EQ)
AUDIOHW_SETTING_ENT(EQ_BAND1_GAIN, sound_set_hw_eq_band1_gain)
diff --git a/firmware/export/sound.h b/firmware/export/sound.h
index 2e04cac854..8e79dd0aed 100644
--- a/firmware/export/sound.h
+++ b/firmware/export/sound.h
@@ -57,6 +57,10 @@ void sound_set_depth_3d(int value);
void sound_set_filter_roll_off(int value);
#endif
+#if defined(AUDIOHW_HAVE_POWER_MODE)
+void sound_set_power_mode(int value);
+#endif
+
#ifdef AUDIOHW_HAVE_EQ
/*
* band = SOUND_EQ_BANDb
diff --git a/firmware/sound.c b/firmware/sound.c
index 71bdc25003..6fe6115406 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -145,6 +145,9 @@ int sound_current(int setting)
#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF)
SOUND_CUR_SET(FILTER_ROLL_OFF, global_settings.roll_off)
#endif
+#if defined(AUDIOHW_HAVE_POWER_MODE)
+ SOUND_CUR_SET(POWER_MODE, global_settings.power_mode)
+#endif
#if 0 /*WRONG -- these need to index the hw_eq_bands[AUDIOHW_EQ_BAND_NUM] struct*/
/* Hardware EQ tone controls */
@@ -425,6 +428,16 @@ void sound_set_filter_roll_off(int value)
}
#endif
+#if defined(AUDIOHW_HAVE_POWER_MODE)
+void sound_set_power_mode(int value)
+{
+ if (!audio_is_initialized)
+ return;
+
+ audiohw_set_power_mode(value);
+}
+#endif
+
#if defined(AUDIOHW_HAVE_EQ)
int sound_enum_hw_eq_band_setting(unsigned int band,
unsigned int band_setting)