diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-01-10 21:50:32 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-01-16 19:35:40 -0500 |
commit | dac3175445b6e76a29c1550da9cece13dfaf7f8c (patch) | |
tree | 2f1475163428f3c5af431b1c3dec630d13365c8f | |
parent | 18b3e91707e42873eab833f0f3da709062207ba7 (diff) | |
download | rockbox-dac3175445b6e76a29c1550da9cece13dfaf7f8c.tar.gz rockbox-dac3175445b6e76a29c1550da9cece13dfaf7f8c.zip |
audiohw: avoid magic numbers for DAC power mode
Define proper symbolic constants for power mode. Also allow
targets to define the default power mode setting.
Change-Id: Ia07cf854dce47d0a6aa88e067471f1ff9fbc45fb
-rw-r--r-- | apps/settings_list.c | 9 | ||||
-rw-r--r-- | firmware/drivers/audio/ak4376.c | 4 | ||||
-rw-r--r-- | firmware/export/ak4376.h | 4 | ||||
-rw-r--r-- | firmware/export/audiohw.h | 6 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_x1000/fiiom3k/audiohw-fiiom3k.c | 2 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_x1000/shanlingq1/audiohw-shanlingq1.c | 2 |
6 files changed, 20 insertions, 7 deletions
diff --git a/apps/settings_list.c b/apps/settings_list.c index 982b483874..795d42ceba 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -351,6 +351,12 @@ static const char graphic_numeric[] = "graphic,numeric"; | |||
351 | # endif | 351 | # endif |
352 | #endif | 352 | #endif |
353 | 353 | ||
354 | #ifdef AUDIOHW_HAVE_POWER_MODE | ||
355 | # ifndef TARGET_DEFAULT_DAC_POWER_MODE | ||
356 | # define TARGET_DEFAULT_DAC_POWER_MODE SOUND_HIGH_POWER | ||
357 | # endif | ||
358 | #endif | ||
359 | |||
354 | #if LCD_DEPTH > 1 | 360 | #if LCD_DEPTH > 1 |
355 | static const char* list_pad_formatter(char *buffer, size_t buffer_size, | 361 | static const char* list_pad_formatter(char *buffer, size_t buffer_size, |
356 | int val, const char *unit) | 362 | int val, const char *unit) |
@@ -877,7 +883,8 @@ const struct settings_list settings[] = { | |||
877 | #endif | 883 | #endif |
878 | 884 | ||
879 | #ifdef AUDIOHW_HAVE_POWER_MODE | 885 | #ifdef AUDIOHW_HAVE_POWER_MODE |
880 | CHOICE_SETTING(F_SOUNDSETTING, power_mode, LANG_DAC_POWER_MODE, 0, | 886 | CHOICE_SETTING(F_SOUNDSETTING, power_mode, LANG_DAC_POWER_MODE, |
887 | TARGET_DEFAULT_DAC_POWER_MODE, | ||
881 | "dac_power_mode", "high,low", sound_set_power_mode, | 888 | "dac_power_mode", "high,low", sound_set_power_mode, |
882 | 2, ID2P(LANG_DAC_POWER_HIGH), ID2P(LANG_DAC_POWER_LOW)), | 889 | 2, ID2P(LANG_DAC_POWER_HIGH), ID2P(LANG_DAC_POWER_LOW)), |
883 | #endif | 890 | #endif |
diff --git a/firmware/drivers/audio/ak4376.c b/firmware/drivers/audio/ak4376.c index 8206bcf7e0..2e772ace84 100644 --- a/firmware/drivers/audio/ak4376.c +++ b/firmware/drivers/audio/ak4376.c | |||
@@ -242,11 +242,11 @@ void ak4376_set_freqmode(int fsel, int mult, int power_mode) | |||
242 | 242 | ||
243 | /* Handle the DSMLP bit in the MODE_CTRL register */ | 243 | /* Handle the DSMLP bit in the MODE_CTRL register */ |
244 | int mode_ctrl = 0x00; | 244 | int mode_ctrl = 0x00; |
245 | if(power_mode || hw_freq_sampr[fsel] <= SAMPR_12) | 245 | if(power_mode == SOUND_LOW_POWER || hw_freq_sampr[fsel] <= SAMPR_12) |
246 | mode_ctrl |= 0x40; | 246 | mode_ctrl |= 0x40; |
247 | 247 | ||
248 | /* Program the new settings */ | 248 | /* Program the new settings */ |
249 | ak4376_write(AK4376_REG_CLOCK_MODE, clock_mode); | 249 | ak4376_write(AK4376_REG_CLOCK_MODE, clock_mode); |
250 | ak4376_write(AK4376_REG_MODE_CTRL, mode_ctrl); | 250 | ak4376_write(AK4376_REG_MODE_CTRL, mode_ctrl); |
251 | ak4376_write(AK4376_REG_PWR3, power_mode ? 0x11 : 0x01); | 251 | ak4376_write(AK4376_REG_PWR3, power_mode == SOUND_LOW_POWER ? 0x11 : 0x01); |
252 | } | 252 | } |
diff --git a/firmware/export/ak4376.h b/firmware/export/ak4376.h index eab0bc24f3..0ae156bc37 100644 --- a/firmware/export/ak4376.h +++ b/firmware/export/ak4376.h | |||
@@ -144,8 +144,8 @@ extern void ak4376_set_filter_roll_off(int val); | |||
144 | * and power-up / power-down sequences as a frequency switch, so both settings | 144 | * and power-up / power-down sequences as a frequency switch, so both settings |
145 | * are controlled by this function. | 145 | * are controlled by this function. |
146 | * | 146 | * |
147 | * high power mode -- use power_mode=0 | 147 | * high power mode -- use power_mode=SOUND_HIGH_POWER |
148 | * low power mode -- use power_mode=1 | 148 | * low power mode -- use power_mode=SOUND_LOW_POWER |
149 | */ | 149 | */ |
150 | extern void ak4376_set_freqmode(int fsel, int mult, int power_mode); | 150 | extern void ak4376_set_freqmode(int fsel, int mult, int power_mode); |
151 | 151 | ||
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index a365b97828..3f8b48d750 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h | |||
@@ -605,6 +605,12 @@ void audiohw_set_filter_roll_off(int val); | |||
605 | #endif | 605 | #endif |
606 | 606 | ||
607 | #ifdef AUDIOHW_HAVE_POWER_MODE | 607 | #ifdef AUDIOHW_HAVE_POWER_MODE |
608 | enum audiohw_power_mode | ||
609 | { | ||
610 | SOUND_HIGH_POWER = 0, | ||
611 | SOUND_LOW_POWER, | ||
612 | }; | ||
613 | |||
608 | /** | 614 | /** |
609 | * Set DAC's power saving mode. | 615 | * Set DAC's power saving mode. |
610 | * @param enable 0 - highest performance, 1 - battery saving | 616 | * @param enable 0 - highest performance, 1 - battery saving |
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/audiohw-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/audiohw-fiiom3k.c index 8528b803f7..f7dced8f54 100644 --- a/firmware/target/mips/ingenic_x1000/fiiom3k/audiohw-fiiom3k.c +++ b/firmware/target/mips/ingenic_x1000/fiiom3k/audiohw-fiiom3k.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "logf.h" | 28 | #include "logf.h" |
29 | 29 | ||
30 | static int cur_fsel = HW_FREQ_48; | 30 | static int cur_fsel = HW_FREQ_48; |
31 | static int cur_power_mode = 0; | 31 | static int cur_power_mode = SOUND_HIGH_POWER; |
32 | 32 | ||
33 | static void set_ak_freqmode(void) | 33 | static void set_ak_freqmode(void) |
34 | { | 34 | { |
diff --git a/firmware/target/mips/ingenic_x1000/shanlingq1/audiohw-shanlingq1.c b/firmware/target/mips/ingenic_x1000/shanlingq1/audiohw-shanlingq1.c index 7314f20412..3b49262f20 100644 --- a/firmware/target/mips/ingenic_x1000/shanlingq1/audiohw-shanlingq1.c +++ b/firmware/target/mips/ingenic_x1000/shanlingq1/audiohw-shanlingq1.c | |||
@@ -154,7 +154,7 @@ void audiohw_set_filter_roll_off(int value) | |||
154 | void audiohw_set_power_mode(int mode) | 154 | void audiohw_set_power_mode(int mode) |
155 | { | 155 | { |
156 | enum es9218_amp_mode new_amp_mode; | 156 | enum es9218_amp_mode new_amp_mode; |
157 | if(mode == 0) | 157 | if(mode == SOUND_HIGH_POWER) |
158 | new_amp_mode = ES9218_AMP_MODE_2VRMS; | 158 | new_amp_mode = ES9218_AMP_MODE_2VRMS; |
159 | else | 159 | else |
160 | new_amp_mode = ES9218_AMP_MODE_1VRMS; | 160 | new_amp_mode = ES9218_AMP_MODE_1VRMS; |