ALSA: oxygen: fix distorted output on AK4396-based cards

When changing the sample rate, the CMI8788's master clock output becomes
unstable for a short time. The AK4396 needs the master clock to do SPI
writes, so writing to an AK4396 control register directly after a sample
rate change will garble the value. In our case, this leads to the DACs
being misconfigured to I2S sample format, which results in a wrong
output level and horrible distortions on samples louder than -6 dB.

To fix this, we need to wait until the new master clock signal has
become stable before doing SPI writes.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by Clemens Ladisch and committed by Takashi Iwai df91bc23 93a1a5eb

+8
+4
sound/pci/oxygen/hifier.c
··· 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 19 20 + #include <linux/delay.h> 20 21 #include <linux/pci.h> 21 22 #include <sound/control.h> 22 23 #include <sound/core.h> ··· 108 107 else 109 108 value |= AK4396_DFS_QUAD; 110 109 data->ak4396_ctl2 = value; 110 + 111 + msleep(1); /* wait for the new MCLK to become stable */ 112 + 111 113 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB); 112 114 ak4396_write(chip, AK4396_CONTROL_2, value); 113 115 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
+4
sound/pci/oxygen/oxygen.c
··· 28 28 * GPIO 1 -> DFS1 of AK5385 29 29 */ 30 30 31 + #include <linux/delay.h> 31 32 #include <linux/mutex.h> 32 33 #include <linux/pci.h> 33 34 #include <sound/ac97_codec.h> ··· 214 213 else 215 214 value |= AK4396_DFS_QUAD; 216 215 data->ak4396_ctl2 = value; 216 + 217 + msleep(1); /* wait for the new MCLK to become stable */ 218 + 217 219 for (i = 0; i < 4; ++i) { 218 220 ak4396_write(chip, i, 219 221 AK4396_CONTROL_1, AK4396_DIF_24_MSB);