diff options
-rw-r--r-- | firmware/drivers/audio/as3514.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index d8572df4d6..6cad8259f7 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c | |||
@@ -131,8 +131,8 @@ void audiohw_preinit(void) | |||
131 | 131 | ||
132 | #ifdef HAVE_AS3543 | 132 | #ifdef HAVE_AS3543 |
133 | 133 | ||
134 | as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on | AUDIOSET1_DAC_GAIN_on); | 134 | as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on); |
135 | as3514_write(AS3514_AUDIOSET2, AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER); | 135 | as3514_write(AS3514_AUDIOSET2, AUDIOSET2_SUM_off | AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER); |
136 | /* common ground on, delay playback unmuting when inserting headphones */ | 136 | /* common ground on, delay playback unmuting when inserting headphones */ |
137 | as3514_write(AS3514_AUDIOSET3, AUDIOSET3_HPCM_on | AUDIOSET3_HP_LONGSTART); | 137 | as3514_write(AS3514_AUDIOSET3, AUDIOSET3_HPCM_on | AUDIOSET3_HP_LONGSTART); |
138 | 138 | ||
@@ -144,8 +144,8 @@ void audiohw_preinit(void) | |||
144 | /* Select Line 2 for FM radio */ | 144 | /* Select Line 2 for FM radio */ |
145 | as3514_set(AS3514_LINE_IN1_R, LINE_IN_R_LINE_SELECT); | 145 | as3514_set(AS3514_LINE_IN1_R, LINE_IN_R_LINE_SELECT); |
146 | #endif | 146 | #endif |
147 | /* Output SUM of microphone/line/DAC */ | 147 | /* Set LINEOUT to minimize pop-click noise in headphone on init stage */ |
148 | as3514_write(AS3514_HPH_OUT_R, HPH_OUT_R_HEADPHONES | HPH_OUT_R_HP_OUT_SUM); | 148 | as3514_write(AS3514_HPH_OUT_R, HPH_OUT_R_LINEOUT | HPH_OUT_R_HP_OUT_DAC); |
149 | 149 | ||
150 | #else | 150 | #else |
151 | /* as3514/as3515 */ | 151 | /* as3514/as3515 */ |
@@ -216,6 +216,11 @@ void audiohw_preinit(void) | |||
216 | 216 | ||
217 | /* DAC_Mute_off */ | 217 | /* DAC_Mute_off */ |
218 | as3514_set(AS3514_DAC_L, DAC_L_DAC_MUTE_off); | 218 | as3514_set(AS3514_DAC_L, DAC_L_DAC_MUTE_off); |
219 | |||
220 | #ifdef HAVE_AS3543 | ||
221 | /* DAC direct - gain, mixer and limitter bypassed */ | ||
222 | as3514_write(AS3514_HPH_OUT_R, HPH_OUT_R_HEADPHONES | HPH_OUT_R_HP_OUT_DAC); | ||
223 | #endif | ||
219 | } | 224 | } |
220 | 225 | ||
221 | static void audiohw_mute(bool mute) | 226 | static void audiohw_mute(bool mute) |
@@ -291,7 +296,21 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
291 | } else { | 296 | } else { |
292 | mix_l = MIXER_MAX_VOLUME; | 297 | mix_l = MIXER_MAX_VOLUME; |
293 | hph_l = vol_l - MIXER_MAX_VOLUME; | 298 | hph_l = vol_l - MIXER_MAX_VOLUME; |
294 | } | 299 | } |
300 | |||
301 | #ifdef HAVE_AS3543 | ||
302 | if (!(as3514_regs[AS3514_HPH_OUT_R] & 0x40)) { /*if not radio or recording*/ | ||
303 | if (!hph_l || !hph_r) { /*if volume higher, disable the mixer to slightly improve noise*/ | ||
304 | as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on | AUDIOSET1_DAC_GAIN_on); | ||
305 | as3514_write(AS3514_AUDIOSET2, AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER); | ||
306 | as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_SUM, HPH_OUT_R_HP_OUT_MASK); | ||
307 | } else { | ||
308 | as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on); | ||
309 | as3514_write(AS3514_AUDIOSET2, AUDIOSET2_SUM_off | AUDIOSET2_AGC_off | AUDIOSET2_HPH_QUALITY_LOW_POWER); | ||
310 | as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_DAC, HPH_OUT_R_HP_OUT_MASK); | ||
311 | } | ||
312 | } | ||
313 | #endif | ||
295 | 314 | ||
296 | as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); | 315 | as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); |
297 | as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); | 316 | as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); |
@@ -464,6 +483,9 @@ void audiohw_set_recvol(int left, int right, int type) | |||
464 | void audiohw_set_monitor(bool enable) | 483 | void audiohw_set_monitor(bool enable) |
465 | { | 484 | { |
466 | if (enable) { | 485 | if (enable) { |
486 | #ifdef HAVE_AS3543 | ||
487 | as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_LINE, HPH_OUT_R_HP_OUT_MASK); | ||
488 | #endif | ||
467 | /* select either LIN1 or LIN2 */ | 489 | /* select either LIN1 or LIN2 */ |
468 | as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN_on, | 490 | as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN_on, |
469 | AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); | 491 | AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); |
@@ -471,6 +493,9 @@ void audiohw_set_monitor(bool enable) | |||
471 | as3514_set(AS3514_LINE_IN_L, LINE_IN1_L_LI1L_MUTE_off); | 493 | as3514_set(AS3514_LINE_IN_L, LINE_IN1_L_LI1L_MUTE_off); |
472 | } | 494 | } |
473 | else { | 495 | else { |
496 | #ifdef HAVE_AS3543 | ||
497 | as3514_write_masked(AS3514_HPH_OUT_R, HPH_OUT_R_HP_OUT_DAC, HPH_OUT_R_HP_OUT_MASK); | ||
498 | #endif | ||
474 | /* turn off both LIN1 and LIN2 (if present) */ | 499 | /* turn off both LIN1 and LIN2 (if present) */ |
475 | as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); | 500 | as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); |
476 | as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); | 501 | as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); |