summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/wm8721.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/wm8721.c')
-rw-r--r--firmware/drivers/audio/wm8721.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/firmware/drivers/audio/wm8721.c b/firmware/drivers/audio/wm8721.c
index 6c4e12b9dc..3f14ca467e 100644
--- a/firmware/drivers/audio/wm8721.c
+++ b/firmware/drivers/audio/wm8721.c
@@ -33,7 +33,6 @@
33 33
34#include "wmcodec.h" 34#include "wmcodec.h"
35#include "audiohw.h" 35#include "audiohw.h"
36#include "i2s.h"
37 36
38#define IPOD_PCM_LEVEL 0x65 /* -6dB */ 37#define IPOD_PCM_LEVEL 0x65 /* -6dB */
39 38
@@ -91,43 +90,38 @@ static void codec_set_active(int active)
91 90
92 91
93/* Silently enable / disable audio output */ 92/* Silently enable / disable audio output */
94void audiohw_enable_output(bool enable) 93void audiohw_preinit(void)
95{ 94{
96 if (enable) 95 wmcodec_write(RESET, 0x0); /*Reset*/
97 {
98 /* reset the I2S controller into known state */
99 i2s_reset();
100
101 wmcodec_write(RESET, 0x0); /*Reset*/
102 96
103 codec_set_active(0x0); 97 codec_set_active(0x0);
104 98
105 /* DACSEL=1 */ 99 /* DACSEL=1 */
106 wmcodec_write(0x4, 0x10); 100 wmcodec_write(0x4, 0x10);
107 101
108 /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */ 102 /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
109 wmcodec_write(PDCTRL, 0x67); 103 wmcodec_write(PDCTRL, 0x67);
110 104
111 /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ 105 /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
112 /* IWL=00(16 bit) FORMAT=10(I2S format) */ 106 /* IWL=00(16 bit) FORMAT=10(I2S format) */
113 wmcodec_write(AINTFCE, 0x42); 107 wmcodec_write(AINTFCE, 0x42);
114 108
115 audiohw_set_sample_rate(WM8721_USB24_44100HZ); 109 audiohw_set_sample_rate(WM8721_USB24_44100HZ);
116 110
117 /* set the volume to -6dB */ 111 /* set the volume to -6dB */
118 wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL); 112 wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL);
119 wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL); 113 wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL);
120 114
121 /* ACTIVE=1 */ 115 /* ACTIVE=1 */
122 codec_set_active(1); 116 codec_set_active(1);
123 117
124 /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */ 118 /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */
125 wmcodec_write(DAPCTRL, 0x0); 119 wmcodec_write(DAPCTRL, 0x0);
120}
126 121
127 audiohw_mute(0); 122void audiohw_postinit(void)
128 } else { 123{
129 audiohw_mute(1); 124 audiohw_mute(0);
130 }
131} 125}
132 126
133void audiohw_set_master_vol(int vol_l, int vol_r) 127void audiohw_set_master_vol(int vol_l, int vol_r)