diff options
Diffstat (limited to 'firmware/drivers/audio/wm8985.c')
-rw-r--r-- | firmware/drivers/audio/wm8985.c | 75 |
1 files changed, 32 insertions, 43 deletions
diff --git a/firmware/drivers/audio/wm8985.c b/firmware/drivers/audio/wm8985.c index 9d80f9e374..0467e3718a 100644 --- a/firmware/drivers/audio/wm8985.c +++ b/firmware/drivers/audio/wm8985.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include "wmcodec.h" | 24 | #include "wmcodec.h" |
25 | #include "audiohw.h" | 25 | #include "audiohw.h" |
26 | #include "i2s.h" | ||
27 | 26 | ||
28 | /* Register addresses as per datasheet Rev.4.4 */ | 27 | /* Register addresses as per datasheet Rev.4.4 */ |
29 | #define RESET 0x00 | 28 | #define RESET 0x00 |
@@ -127,57 +126,50 @@ int tenthdb2master(int db) | |||
127 | } | 126 | } |
128 | 127 | ||
129 | /* Silently enable / disable audio output */ | 128 | /* Silently enable / disable audio output */ |
130 | void audiohw_enable_output(bool enable) | 129 | void audiohw_preinit(void) |
131 | { | 130 | { |
132 | if (enable) | 131 | wmcodec_write(RESET, 0x1ff); /* Reset */ |
133 | { | ||
134 | /* TODO: reset the I2S controller into known state */ | ||
135 | //i2s_reset(); | ||
136 | 132 | ||
137 | wmcodec_write(RESET, 0x1ff); /* Reset */ | 133 | wmcodec_write(BIASCTL, 0x100); /* BIASCUT = 1 */ |
134 | wmcodec_write(OUTCTRL, 0x6); /* Thermal shutdown */ | ||
138 | 135 | ||
139 | wmcodec_write(BIASCTL, 0x100); /* BIASCUT = 1 */ | 136 | wmcodec_write(PWRMGMT1, 0x8); /* BIASEN = 1 */ |
140 | wmcodec_write(OUTCTRL, 0x6); /* Thermal shutdown */ | ||
141 | 137 | ||
142 | wmcodec_write(PWRMGMT1, 0x8); /* BIASEN = 1 */ | 138 | /* Volume zero, mute all outputs */ |
139 | wmcodec_write(LOUT1VOL, 0x140); | ||
140 | wmcodec_write(ROUT1VOL, 0x140); | ||
141 | wmcodec_write(LOUT2VOL, 0x140); | ||
142 | wmcodec_write(ROUT2VOL, 0x140); | ||
143 | wmcodec_write(OUT3MIX, 0x40); | ||
144 | wmcodec_write(OUT4MIX, 0x40); | ||
143 | 145 | ||
144 | /* Volume zero, mute all outputs */ | 146 | /* DAC softmute, automute, 128OSR */ |
145 | wmcodec_write(LOUT1VOL, 0x140); | 147 | wmcodec_write(DACCTRL, 0x4c); |
146 | wmcodec_write(ROUT1VOL, 0x140); | ||
147 | wmcodec_write(LOUT2VOL, 0x140); | ||
148 | wmcodec_write(ROUT2VOL, 0x140); | ||
149 | wmcodec_write(OUT3MIX, 0x40); | ||
150 | wmcodec_write(OUT4MIX, 0x40); | ||
151 | |||
152 | /* DAC softmute, automute, 128OSR */ | ||
153 | wmcodec_write(DACCTRL, 0x4c); | ||
154 | 148 | ||
155 | wmcodec_write(OUT4ADC, 0x2); /* POBCTRL = 1 */ | 149 | wmcodec_write(OUT4ADC, 0x2); /* POBCTRL = 1 */ |
156 | 150 | ||
157 | /* Enable output, DAC and mixer */ | 151 | /* Enable output, DAC and mixer */ |
158 | wmcodec_write(PWRMGMT3, 0x6f); | 152 | wmcodec_write(PWRMGMT3, 0x6f); |
159 | wmcodec_write(PWRMGMT2, 0x180); | 153 | wmcodec_write(PWRMGMT2, 0x180); |
160 | wmcodec_write(PWRMGMT1, 0xd); | 154 | wmcodec_write(PWRMGMT1, 0xd); |
161 | wmcodec_write(LOUTMIX, 0x1); | 155 | wmcodec_write(LOUTMIX, 0x1); |
162 | wmcodec_write(ROUTMIX, 0x1); | 156 | wmcodec_write(ROUTMIX, 0x1); |
163 | 157 | ||
164 | /* Disable clock since we're acting as slave to the SoC */ | 158 | /* Disable clock since we're acting as slave to the SoC */ |
165 | wmcodec_write(CLKGEN, 0x0); | 159 | wmcodec_write(CLKGEN, 0x0); |
166 | wmcodec_write(AINTFCE, 0x10); /* 16-bit, I2S format */ | 160 | wmcodec_write(AINTFCE, 0x10); /* 16-bit, I2S format */ |
167 | 161 | ||
168 | wmcodec_write(LDACVOL, 0x1ff); /* Full DAC digital vol */ | 162 | wmcodec_write(LDACVOL, 0x1ff); /* Full DAC digital vol */ |
169 | wmcodec_write(RDACVOL, 0x1ff); | 163 | wmcodec_write(RDACVOL, 0x1ff); |
170 | 164 | ||
171 | wmcodec_write(OUT4ADC, 0x0); /* POBCTRL = 0 */ | 165 | wmcodec_write(OUT4ADC, 0x0); /* POBCTRL = 0 */ |
166 | } | ||
172 | 167 | ||
173 | sleep(HZ/2); | 168 | void audiohw_postinit(void) |
169 | { | ||
170 | sleep(HZ/2); | ||
174 | 171 | ||
175 | audiohw_mute(0); | 172 | audiohw_mute(0); |
176 | } | ||
177 | else | ||
178 | { | ||
179 | audiohw_mute(1); | ||
180 | } | ||
181 | } | 173 | } |
182 | 174 | ||
183 | void audiohw_set_headphone_vol(int vol_l, int vol_r) | 175 | void audiohw_set_headphone_vol(int vol_l, int vol_r) |
@@ -256,9 +248,6 @@ void audiohw_enable_recording(bool source_mic) | |||
256 | { | 248 | { |
257 | (void)source_mic; /* We only have a line-in (I think) */ | 249 | (void)source_mic; /* We only have a line-in (I think) */ |
258 | 250 | ||
259 | /* TODO: reset the I2S controller into known state */ | ||
260 | //i2s_reset(); | ||
261 | |||
262 | wmcodec_write(RESET, 0x1ff); /*Reset*/ | 251 | wmcodec_write(RESET, 0x1ff); /*Reset*/ |
263 | 252 | ||
264 | wmcodec_write(PWRMGMT1, 0x2b); | 253 | wmcodec_write(PWRMGMT1, 0x2b); |