diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-03-13 02:11:45 +0000 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-03-22 13:00:11 +0000 |
commit | 55805e13a4ef0152b40e6606fce8b4603ae8cb91 (patch) | |
tree | 34171877486e5732233439ef1058007cad36ed29 /firmware | |
parent | 3a254a92c7363aad95cfcc549732e44d9eddc42b (diff) | |
download | rockbox-55805e13a4ef0152b40e6606fce8b4603ae8cb91.tar.gz 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.c | 4 | ||||
-rw-r--r-- | firmware/export/audiohw.h | 15 | ||||
-rw-r--r-- | firmware/export/audiohw_settings.h | 3 | ||||
-rw-r--r-- | firmware/export/sound.h | 4 | ||||
-rw-r--r-- | firmware/sound.c | 13 |
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) | |||
118 | void audiohw_set_filter_roll_off(int value) | 118 | void audiohw_set_filter_roll_off(int value) |
119 | { (void)value; } | 119 | { (void)value; } |
120 | #endif | 120 | #endif |
121 | #if defined(AUDIOHW_HAVE_POWER_MODE) | ||
122 | void audiohw_set_power_mode(int value) | ||
123 | { (void)value; } | ||
124 | #endif | ||
121 | 125 | ||
122 | void audiohw_close(void) {} | 126 | void audiohw_close(void) {} |
123 | 127 | ||
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 @@ | |||
41 | #define LIN_GAIN_CAP (1 << 11) | 41 | #define LIN_GAIN_CAP (1 << 11) |
42 | #define MIC_GAIN_CAP (1 << 12) | 42 | #define MIC_GAIN_CAP (1 << 12) |
43 | #define FILTER_ROLL_OFF_CAP (1 << 13) | 43 | #define FILTER_ROLL_OFF_CAP (1 << 13) |
44 | #define POWER_MODE_CAP (1 << 14) | ||
44 | 45 | ||
45 | /* Used by every driver to export its min/max/default values for its audio | 46 | /* Used by every driver to export its min/max/default values for its audio |
46 | settings. */ | 47 | settings. */ |
@@ -391,6 +392,10 @@ enum AUDIOHW_EQ_SETTINGS | |||
391 | #define AUDIOHW_HAVE_FILTER_ROLL_OFF | 392 | #define AUDIOHW_HAVE_FILTER_ROLL_OFF |
392 | #endif | 393 | #endif |
393 | 394 | ||
395 | #if (AUDIOHW_CAPS & POWER_MODE_CAP) | ||
396 | #define AUDIOHW_HAVE_POWER_MODE | ||
397 | #endif | ||
398 | |||
394 | #endif /* AUDIOHW_CAPS */ | 399 | #endif /* AUDIOHW_CAPS */ |
395 | 400 | ||
396 | #ifdef HAVE_SW_TONE_CONTROLS | 401 | #ifdef HAVE_SW_TONE_CONTROLS |
@@ -586,6 +591,16 @@ void audiohw_set_depth_3d(int val); | |||
586 | void audiohw_set_filter_roll_off(int val); | 591 | void audiohw_set_filter_roll_off(int val); |
587 | #endif | 592 | #endif |
588 | 593 | ||
594 | #ifdef AUDIOHW_HAVE_POWER_MODE | ||
595 | /** | ||
596 | * Set DAC's power saving mode. | ||
597 | * @param enable 0 - highest performance, 1 - battery saving | ||
598 | * NOTE: AUDIOHW_CAPS need to contain | ||
599 | * POWER_MODE_CAP | ||
600 | */ | ||
601 | void audiohw_set_power_mode(int mode); | ||
602 | #endif | ||
603 | |||
589 | void audiohw_set_frequency(int fsel); | 604 | void audiohw_set_frequency(int fsel); |
590 | 605 | ||
591 | #ifdef HAVE_RECORDING | 606 | #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( | |||
103 | #if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF) | 103 | #if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF) |
104 | AUDIOHW_SETTING_ENT(FILTER_ROLL_OFF, sound_set_filter_roll_off) | 104 | AUDIOHW_SETTING_ENT(FILTER_ROLL_OFF, sound_set_filter_roll_off) |
105 | #endif | 105 | #endif |
106 | #if defined(AUDIOHW_HAVE_POWER_MODE) | ||
107 | AUDIOHW_SETTING_ENT(POWER_MODE, sound_set_power_mode) | ||
108 | #endif | ||
106 | /* Hardware EQ tone controls */ | 109 | /* Hardware EQ tone controls */ |
107 | #if defined(AUDIOHW_HAVE_EQ) | 110 | #if defined(AUDIOHW_HAVE_EQ) |
108 | AUDIOHW_SETTING_ENT(EQ_BAND1_GAIN, sound_set_hw_eq_band1_gain) | 111 | 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); | |||
57 | void sound_set_filter_roll_off(int value); | 57 | void sound_set_filter_roll_off(int value); |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #if defined(AUDIOHW_HAVE_POWER_MODE) | ||
61 | void sound_set_power_mode(int value); | ||
62 | #endif | ||
63 | |||
60 | #ifdef AUDIOHW_HAVE_EQ | 64 | #ifdef AUDIOHW_HAVE_EQ |
61 | /* | 65 | /* |
62 | * band = SOUND_EQ_BANDb | 66 | * 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) | |||
145 | #if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF) | 145 | #if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF) |
146 | SOUND_CUR_SET(FILTER_ROLL_OFF, global_settings.roll_off) | 146 | SOUND_CUR_SET(FILTER_ROLL_OFF, global_settings.roll_off) |
147 | #endif | 147 | #endif |
148 | #if defined(AUDIOHW_HAVE_POWER_MODE) | ||
149 | SOUND_CUR_SET(POWER_MODE, global_settings.power_mode) | ||
150 | #endif | ||
148 | 151 | ||
149 | #if 0 /*WRONG -- these need to index the hw_eq_bands[AUDIOHW_EQ_BAND_NUM] struct*/ | 152 | #if 0 /*WRONG -- these need to index the hw_eq_bands[AUDIOHW_EQ_BAND_NUM] struct*/ |
150 | /* Hardware EQ tone controls */ | 153 | /* Hardware EQ tone controls */ |
@@ -425,6 +428,16 @@ void sound_set_filter_roll_off(int value) | |||
425 | } | 428 | } |
426 | #endif | 429 | #endif |
427 | 430 | ||
431 | #if defined(AUDIOHW_HAVE_POWER_MODE) | ||
432 | void sound_set_power_mode(int value) | ||
433 | { | ||
434 | if (!audio_is_initialized) | ||
435 | return; | ||
436 | |||
437 | audiohw_set_power_mode(value); | ||
438 | } | ||
439 | #endif | ||
440 | |||
428 | #if defined(AUDIOHW_HAVE_EQ) | 441 | #if defined(AUDIOHW_HAVE_EQ) |
429 | int sound_enum_hw_eq_band_setting(unsigned int band, | 442 | int sound_enum_hw_eq_band_setting(unsigned int band, |
430 | unsigned int band_setting) | 443 | unsigned int band_setting) |