ErosQNative: Initialize AIC FIFO to -1

Write -1 to AIC_DR to initialize the "last sample"
to -1 in order to prevent power-on clicks.

It appears necessary to completely fill the FIFO,
otherwise I was able to get a click out of it, however
uncommon it was.

Not only does this prevent a click when first
playing a song after power-on, but it also seems to prevent
any click at all when powering on - previously, a small
click may have been heard when first booting.

Change-Id: I2b81c2fa6af9809ef1c354d7a08ca8f9893a7690
This commit is contained in:
Dana Conrad 2021-10-05 10:59:33 -05:00 committed by Aidan MacDonald
parent 465c216636
commit 67d4da5342
1 changed files with 17 additions and 0 deletions

View File

@ -47,6 +47,7 @@ void audiohw_init(void)
aic_set_i2s_mode(AIC_I2S_MASTER_MODE);
audiohw_set_frequency(HW_FREQ_48);
aic_set_play_last_sample(true);
aic_enable_i2s_master_clock(true);
aic_enable_i2s_bit_clock(true);
@ -59,6 +60,22 @@ void audiohw_init(void)
void audiohw_postinit(void)
{
/*
* enable playback, fill FIFO buffer with -1 to prevent
* the DAC from auto-muting, wait, and then stop playback.
* This seems to completely prevent power-on or first-track
* clicking.
*/
jz_writef(AIC_CCR, ERPL(1));
for (int i = 0; i < 32; i++)
{
jz_write(AIC_DR, 0xFFFFFF);
}
/* Wait until all samples are through the FIFO. */
while(jz_readf(AIC_SR, TFL) != 0);
mdelay(20); /* This seems to silence the power-on click */
jz_writef(AIC_CCR, ERPL(0));
/* unmute - attempt to make power-on pop-free */
gpio_set_level(GPIO_ISL54405_SEL, 0);
gpio_set_level(GPIO_MAX97220_SHDN, 1);