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.

m3k: don't use mixer controls for volume control

According to a forum user, there's an audible click when changing
the volume between -32 and -32.5 dB with some headphones. Fix this
by not (ab)using the DAC digital mixer for volume control.

The mixer only provides an extra -6 dB of hardware volume range,
so the only side effect is that software volume will now kick in
at -32 dB instead of -38 dB.

Change-Id: If24d9bc0058eff3c1a29aefb155a2e378522623c

+8 -14
+8 -14
firmware/drivers/audio/ak4376.c
··· 83 83 ak4376_set_pdn_pin(1); 84 84 mdelay(1); 85 85 86 - static const int init_config[] = { 86 + static const uint8_t init_config[] = { 87 87 /* Ensure HPRHZ, HPLHZ are 0 */ 88 88 AK4376_REG_OUTPUT_MODE, 0x00, 89 89 /* Mute all volume controls */ 90 - AK4376_REG_MIXER, 0x00, 90 + AK4376_REG_MIXER, AK4376_MIX_LCH | (AK4376_MIX_RCH << 4), 91 91 AK4376_REG_LCH_VOLUME, 0x80, 92 92 AK4376_REG_RCH_VOLUME, 0x00, 93 93 AK4376_REG_AMP_VOLUME, 0x00, ··· 150 150 return x - rem; 151 151 } 152 152 153 - static void calc_volumes(int vol, int* mix, int* dig, int* sw) 153 + static void calc_volumes(int vol, int* dig, int* sw) 154 154 { 155 - /* Mixer can divide by 2, which gives an extra -6 dB adjustment */ 156 - if(vol < AK4376_DIG_VOLUME_MIN) { 157 - *mix |= AK4376_MIX_HALF; 158 - vol += 60; 159 - } 160 - 155 + /* Apply digital volume */ 161 156 *dig = round_step_up(vol, AK4376_DIG_VOLUME_STEP); 162 157 *dig = MIN(*dig, AK4376_DIG_VOLUME_MAX); 163 158 *dig = MAX(*dig, AK4376_DIG_VOLUME_MIN); ··· 186 181 void ak4376_set_volume(int vol_l, int vol_r) 187 182 { 188 183 int amp; 189 - int mix_l = AK4376_MIX_LCH, dig_l, sw_l; 190 - int mix_r = AK4376_MIX_RCH, dig_r, sw_r; 184 + int dig_l, sw_l; 185 + int dig_r, sw_r; 191 186 192 187 if(vol_l <= AK4376_MIN_VOLUME && vol_r <= AK4376_MIN_VOLUME) { 193 188 /* Special case for full mute */ ··· 202 197 amp = MAX(amp, AK4376_AMP_VOLUME_MIN); 203 198 204 199 /* Other controls are stereo */ 205 - calc_volumes(vol_l - amp, &mix_l, &dig_l, &sw_l); 206 - calc_volumes(vol_r - amp, &mix_r, &dig_r, &sw_r); 200 + calc_volumes(vol_l - amp, &dig_l, &sw_l); 201 + calc_volumes(vol_r - amp, &dig_r, &sw_r); 207 202 } 208 203 209 - ak4376_write(AK4376_REG_MIXER, (mix_l & 0xf) | ((mix_r & 0xf) << 4)); 210 204 ak4376_write(AK4376_REG_LCH_VOLUME, dig_vol_to_hw(dig_l) | (1 << 7)); 211 205 ak4376_write(AK4376_REG_RCH_VOLUME, dig_vol_to_hw(dig_r)); 212 206 ak4376_write(AK4376_REG_AMP_VOLUME, amp_vol_to_hw(amp));