mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
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
This commit is contained in:
parent
18b3e91707
commit
dac3175445
6 changed files with 20 additions and 7 deletions
|
|
@ -351,6 +351,12 @@ static const char graphic_numeric[] = "graphic,numeric";
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef AUDIOHW_HAVE_POWER_MODE
|
||||
# ifndef TARGET_DEFAULT_DAC_POWER_MODE
|
||||
# define TARGET_DEFAULT_DAC_POWER_MODE SOUND_HIGH_POWER
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if LCD_DEPTH > 1
|
||||
static const char* list_pad_formatter(char *buffer, size_t buffer_size,
|
||||
int val, const char *unit)
|
||||
|
|
@ -877,7 +883,8 @@ const struct settings_list settings[] = {
|
|||
#endif
|
||||
|
||||
#ifdef AUDIOHW_HAVE_POWER_MODE
|
||||
CHOICE_SETTING(F_SOUNDSETTING, power_mode, LANG_DAC_POWER_MODE, 0,
|
||||
CHOICE_SETTING(F_SOUNDSETTING, power_mode, LANG_DAC_POWER_MODE,
|
||||
TARGET_DEFAULT_DAC_POWER_MODE,
|
||||
"dac_power_mode", "high,low", sound_set_power_mode,
|
||||
2, ID2P(LANG_DAC_POWER_HIGH), ID2P(LANG_DAC_POWER_LOW)),
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -242,11 +242,11 @@ void ak4376_set_freqmode(int fsel, int mult, int power_mode)
|
|||
|
||||
/* Handle the DSMLP bit in the MODE_CTRL register */
|
||||
int mode_ctrl = 0x00;
|
||||
if(power_mode || hw_freq_sampr[fsel] <= SAMPR_12)
|
||||
if(power_mode == SOUND_LOW_POWER || hw_freq_sampr[fsel] <= SAMPR_12)
|
||||
mode_ctrl |= 0x40;
|
||||
|
||||
/* Program the new settings */
|
||||
ak4376_write(AK4376_REG_CLOCK_MODE, clock_mode);
|
||||
ak4376_write(AK4376_REG_MODE_CTRL, mode_ctrl);
|
||||
ak4376_write(AK4376_REG_PWR3, power_mode ? 0x11 : 0x01);
|
||||
ak4376_write(AK4376_REG_PWR3, power_mode == SOUND_LOW_POWER ? 0x11 : 0x01);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,8 +144,8 @@ extern void ak4376_set_filter_roll_off(int val);
|
|||
* and power-up / power-down sequences as a frequency switch, so both settings
|
||||
* are controlled by this function.
|
||||
*
|
||||
* high power mode -- use power_mode=0
|
||||
* low power mode -- use power_mode=1
|
||||
* high power mode -- use power_mode=SOUND_HIGH_POWER
|
||||
* low power mode -- use power_mode=SOUND_LOW_POWER
|
||||
*/
|
||||
extern void ak4376_set_freqmode(int fsel, int mult, int power_mode);
|
||||
|
||||
|
|
|
|||
|
|
@ -605,6 +605,12 @@ void audiohw_set_filter_roll_off(int val);
|
|||
#endif
|
||||
|
||||
#ifdef AUDIOHW_HAVE_POWER_MODE
|
||||
enum audiohw_power_mode
|
||||
{
|
||||
SOUND_HIGH_POWER = 0,
|
||||
SOUND_LOW_POWER,
|
||||
};
|
||||
|
||||
/**
|
||||
* Set DAC's power saving mode.
|
||||
* @param enable 0 - highest performance, 1 - battery saving
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "logf.h"
|
||||
|
||||
static int cur_fsel = HW_FREQ_48;
|
||||
static int cur_power_mode = 0;
|
||||
static int cur_power_mode = SOUND_HIGH_POWER;
|
||||
|
||||
static void set_ak_freqmode(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ void audiohw_set_filter_roll_off(int value)
|
|||
void audiohw_set_power_mode(int mode)
|
||||
{
|
||||
enum es9218_amp_mode new_amp_mode;
|
||||
if(mode == 0)
|
||||
if(mode == SOUND_HIGH_POWER)
|
||||
new_amp_mode = ES9218_AMP_MODE_2VRMS;
|
||||
else
|
||||
new_amp_mode = ES9218_AMP_MODE_1VRMS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue