diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-01-10 22:33:42 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-01-16 19:35:40 -0500 |
commit | d93e0544198b75542b23b02a8b819d81e98ff880 (patch) | |
tree | 95d99b92e02d8b2e68b1ba16a10e63b0308f44b4 /firmware/drivers/audio/ak4376.c | |
parent | dac3175445b6e76a29c1550da9cece13dfaf7f8c (diff) | |
download | rockbox-d93e0544198b75542b23b02a8b819d81e98ff880.tar.gz rockbox-d93e0544198b75542b23b02a8b819d81e98ff880.zip |
fiiom3k: power down amp before switching DAC power modes
As detailed in the <Low Power Mode> section of the AK4376A
datasheet, the amp should be powered down before switching
power modes (or to a sample rate <= 12 KHz).
Change-Id: I3ab0a21c78a3ad2bb418b64c916f7dbe2a843efa
Diffstat (limited to 'firmware/drivers/audio/ak4376.c')
-rw-r--r-- | firmware/drivers/audio/ak4376.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/firmware/drivers/audio/ak4376.c b/firmware/drivers/audio/ak4376.c index 2e772ace84..8d2b9f44f3 100644 --- a/firmware/drivers/audio/ak4376.c +++ b/firmware/drivers/audio/ak4376.c | |||
@@ -245,8 +245,26 @@ void ak4376_set_freqmode(int fsel, int mult, int power_mode) | |||
245 | if(power_mode == SOUND_LOW_POWER || 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 | /* Handle the LPMODE bit */ | ||
249 | int pwr3 = power_mode == SOUND_LOW_POWER ? 0x11 : 0x01; | ||
250 | |||
251 | /* The datasheet says the HP amp must be powered down before changing | ||
252 | * the operating mode of the DAC or HP amp. I'm assuming this means | ||
253 | * the amp must be shut down when changing DSMLP or LPMODE. */ | ||
254 | int cur_mode_ctrl = ak4376_read(AK4376_REG_MODE_CTRL); | ||
255 | int cur_pwr3 = ak4376_read(AK4376_REG_PWR3); | ||
256 | bool disable_amp = mode_ctrl != cur_mode_ctrl || pwr3 != cur_pwr3; | ||
257 | |||
248 | /* Program the new settings */ | 258 | /* Program the new settings */ |
259 | if(disable_amp) | ||
260 | ak4376_write(AK4376_REG_PWR4, 0x00); | ||
261 | |||
249 | ak4376_write(AK4376_REG_CLOCK_MODE, clock_mode); | 262 | ak4376_write(AK4376_REG_CLOCK_MODE, clock_mode); |
250 | ak4376_write(AK4376_REG_MODE_CTRL, mode_ctrl); | 263 | ak4376_write(AK4376_REG_MODE_CTRL, mode_ctrl); |
251 | ak4376_write(AK4376_REG_PWR3, power_mode == SOUND_LOW_POWER ? 0x11 : 0x01); | 264 | ak4376_write(AK4376_REG_PWR3, pwr3); |
265 | |||
266 | if(disable_amp) { | ||
267 | ak4376_write(AK4376_REG_PWR4, 0x03); | ||
268 | mdelay(26); | ||
269 | } | ||
252 | } | 270 | } |