Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

STMP37xx/iMX233: reduce popping noise on power on/off (Version 1)

Version 1: this patch prolongs startup time by 2 seconds, because the
sleep happens early before other threads have started.

The patch is tested on CreativeZEN and Fuze+.

The datasheet was not very helpfull, so some experimentation was needed.
I came to the following conclusions:
* setting HP to ground:
to prevent popping noises, the headphone output can be set to ground.
This however must be done before any part of the audioout module is
powered up (setting HP to ground itself will lead to a pop otherwise).
This consequently means that HP must NOT be set to ground for powerdown
sequence!
Further study showed that setting HP out to ground has no audible benefit,
controversly not setting/resetting allows for noiseless RoLo-ing.
* headphone amp class A/AB mode:
initially the HP amp is in class A mode, and should be set to
class AB before playing audio, as the datasheet mentions.
If the HP output is set to ground, it must be released BEFORE
setting class AB! Releasing from ground while in AB mode leads
to a very loud pop!
* release HP from ground:
as said before: never release the HP from ground if the HP amp is
set to class AB mode. Therefore the correct order is to power up the
headphone amp, wait some time, release HP from ground, and then
set the amp to class AB mode.
To prevent pop, some time is needed before releasing the HP from gnd.
On CreativeZEN 2 sec seems to be ideal; 1 sec have no audible effect,
1.5 sec softenes the pop to some degree.
* shutting player off
The popping noise when shutting off is much quieter that on power up,
so depopping measures are not absolutely necessary.
However the power off pop can be silenced by inserting a wait time
after the audioout block is closed and before the rest of the chip
is powered down. The longer the better, a time of 5 sec practically
eliminates the pop.

Note that RoLo-ing can still produce noise, because the audio device
is not properly shut down.

Change-Id: Ib20e1d613b346433d2a711c442e303ededc26e78

authored by

Sebastian Leonhardt and committed by
Aidan MacDonald
9aafbf9c 945ce060

+14 -7
+14 -7
firmware/target/arm/imx233/audioout-imx233.c
··· 54 54 55 55 void imx233_audioout_preinit(void) 56 56 { 57 + /* we forego setting HP output to ground; it seems it doesn't have an 58 + audible benefit, but produces loud noise if done at the wrong place */ 59 + /* when RoLo-ing the headphone is still unmuted; mute to reduce noise */ 60 + BF_SET(AUDIOOUT_HPVOL, MUTE); 57 61 /* Enable AUDIOOUT block */ 58 62 imx233_reset_block(&HW_AUDIOOUT_CTRL); 59 63 /* Enable digital filter clock */ ··· 70 74 BF_SET(AUDIOOUT_CTRL, WORD_LENGTH); 71 75 /* Power up DAC */ 72 76 BF_CLR(AUDIOOUT_PWRDN, DAC); 73 - /* Hold HP to ground to avoid pop, then release and power up HP */ 74 - BF_SET(AUDIOOUT_ANACTRL, HP_HOLD_GND); 77 + /* power up HP */ 75 78 BF_CLR(AUDIOOUT_PWRDN, HEADPHONE); 76 - /* Set HP mode to AB */ 79 + /* wait until voltages have settled after powering on HP amp. 80 + * The time delay may be target dependant; on CreativeZEN (STMP3760) 81 + * 1.5 sec still isn't enough (only softening the pop) */ 82 + sleep(HZ*2); 83 + /* Set HP mode to class AB. This must be done after HP is released from 84 + * GND; releasing while AB mode is activated leads to a REALLY loud pop! */ 77 85 BF_SET(AUDIOOUT_ANACTRL, HP_CLASSAB); 78 86 /* change bias to -50% */ 79 87 BF_WR(AUDIOOUT_TEST, HP_I1_ADJ(1)); ··· 82 90 BF_SET(AUDIOOUT_REFCTRL, RAISE_REF); 83 91 #endif 84 92 BF_SET(AUDIOOUT_REFCTRL, XTAL_BGR_BIAS); 85 - /* Stop holding to ground */ 86 - BF_CLR(AUDIOOUT_ANACTRL, HP_HOLD_GND); 87 93 /* Set dmawait count to 31 (see errata, workaround random stop) */ 88 94 BF_WR(AUDIOOUT_CTRL, DMAWAIT_COUNT(31)); 89 95 /* start converting audio */ ··· 107 113 { 108 114 /* Switch to class A */ 109 115 BF_CLR(AUDIOOUT_ANACTRL, HP_CLASSAB); 110 - /* Hold HP to ground */ 111 - BF_SET(AUDIOOUT_ANACTRL, HP_HOLD_GND); 112 116 /* Mute HP and power down */ 113 117 BF_SET(AUDIOOUT_HPVOL, MUTE); 114 118 /* Power down HP */ ··· 123 127 imx233_clkctrl_enable(CLK_FILT, false); 124 128 /* will also gate off the module */ 125 129 BF_CLR(AUDIOOUT_CTRL, RUN); 130 + /* power-off-pop is reduced when waiting after shutting off 131 + * the audioout module and before powering down the whole chip. */ 132 + sleep(HZ*2); 126 133 } 127 134 128 135 /* volume in half dB