diff options
Diffstat (limited to 'firmware/drivers/wm8758.c')
-rw-r--r-- | firmware/drivers/wm8758.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/firmware/drivers/wm8758.c b/firmware/drivers/wm8758.c index aec6f3b598..7c9ac77395 100644 --- a/firmware/drivers/wm8758.c +++ b/firmware/drivers/wm8758.c | |||
@@ -86,8 +86,7 @@ void wm8758_write(int reg, int data) | |||
86 | * Note, I'm using the WM8750 datasheet as its apparently close. | 86 | * Note, I'm using the WM8750 datasheet as its apparently close. |
87 | */ | 87 | */ |
88 | int wmcodec_init(void) { | 88 | int wmcodec_init(void) { |
89 | /* reset I2C */ | 89 | int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL); |
90 | i2c_init(); | ||
91 | 90 | ||
92 | /* normal outputs for CDI and I2S pin groups */ | 91 | /* normal outputs for CDI and I2S pin groups */ |
93 | outl(inl(0x70000020) & ~0x300, 0x70000020); | 92 | outl(inl(0x70000020) & ~0x300, 0x70000020); |
@@ -109,6 +108,7 @@ int wmcodec_init(void) { | |||
109 | /* external dev clock to 24MHz */ | 108 | /* external dev clock to 24MHz */ |
110 | outl(inl(0x70000018) & ~0xc, 0x70000018); | 109 | outl(inl(0x70000018) & ~0xc, 0x70000018); |
111 | 110 | ||
111 | set_irq_level(old_irq_level); | ||
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
114 | 114 | ||
@@ -117,6 +117,8 @@ void wmcodec_enable_output(bool enable) | |||
117 | { | 117 | { |
118 | if (enable) | 118 | if (enable) |
119 | { | 119 | { |
120 | int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
121 | |||
120 | /* reset the I2S controller into known state */ | 122 | /* reset the I2S controller into known state */ |
121 | i2s_reset(); | 123 | i2s_reset(); |
122 | 124 | ||
@@ -140,6 +142,7 @@ void wmcodec_enable_output(bool enable) | |||
140 | wm8758_write(LOUTMIX,0x1); /* Enable mixer */ | 142 | wm8758_write(LOUTMIX,0x1); /* Enable mixer */ |
141 | wm8758_write(ROUTMIX,0x1); /* Enable mixer */ | 143 | wm8758_write(ROUTMIX,0x1); /* Enable mixer */ |
142 | wmcodec_mute(0); | 144 | wmcodec_mute(0); |
145 | set_irq_level(old_irq_level); | ||
143 | } else { | 146 | } else { |
144 | wmcodec_mute(1); | 147 | wmcodec_mute(1); |
145 | } | 148 | } |
@@ -147,6 +150,7 @@ void wmcodec_enable_output(bool enable) | |||
147 | 150 | ||
148 | int wmcodec_set_master_vol(int vol_l, int vol_r) | 151 | int wmcodec_set_master_vol(int vol_l, int vol_r) |
149 | { | 152 | { |
153 | int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
150 | /* OUT1 */ | 154 | /* OUT1 */ |
151 | wm8758_write(LOUT1VOL, vol_l); | 155 | wm8758_write(LOUT1VOL, vol_l); |
152 | wm8758_write(ROUT1VOL, 0x100 | vol_r); | 156 | wm8758_write(ROUT1VOL, 0x100 | vol_r); |
@@ -154,6 +158,8 @@ int wmcodec_set_master_vol(int vol_l, int vol_r) | |||
154 | /* OUT2 */ | 158 | /* OUT2 */ |
155 | wm8758_write(LOUT2VOL, vol_l); | 159 | wm8758_write(LOUT2VOL, vol_l); |
156 | wm8758_write(ROUT2VOL, 0x100 | vol_r); | 160 | wm8758_write(ROUT2VOL, 0x100 | vol_r); |
161 | |||
162 | set_irq_level(old_irq_level); | ||
157 | 163 | ||
158 | return 0; | 164 | return 0; |
159 | } | 165 | } |
@@ -198,6 +204,8 @@ void wmcodec_set_treble(int value) | |||
198 | 204 | ||
199 | int wmcodec_mute(int mute) | 205 | int wmcodec_mute(int mute) |
200 | { | 206 | { |
207 | int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
208 | |||
201 | if (mute) | 209 | if (mute) |
202 | { | 210 | { |
203 | /* Set DACMU = 1 to soft-mute the audio DACs. */ | 211 | /* Set DACMU = 1 to soft-mute the audio DACs. */ |
@@ -207,12 +215,16 @@ int wmcodec_mute(int mute) | |||
207 | wm8758_write(DACCTRL, 0x0); | 215 | wm8758_write(DACCTRL, 0x0); |
208 | } | 216 | } |
209 | 217 | ||
218 | set_irq_level(old_irq_level); | ||
219 | |||
210 | return 0; | 220 | return 0; |
211 | } | 221 | } |
212 | 222 | ||
213 | /* Nice shutdown of WM8758 codec */ | 223 | /* Nice shutdown of WM8758 codec */ |
214 | void wmcodec_close(void) | 224 | void wmcodec_close(void) |
215 | { | 225 | { |
226 | int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
227 | |||
216 | wmcodec_mute(1); | 228 | wmcodec_mute(1); |
217 | 229 | ||
218 | wm8758_write(PWRMGMT3, 0x0); | 230 | wm8758_write(PWRMGMT3, 0x0); |
@@ -220,6 +232,8 @@ void wmcodec_close(void) | |||
220 | wm8758_write(PWRMGMT1, 0x0); | 232 | wm8758_write(PWRMGMT1, 0x0); |
221 | 233 | ||
222 | wm8758_write(PWRMGMT2, 0x40); | 234 | wm8758_write(PWRMGMT2, 0x40); |
235 | |||
236 | set_irq_level(old_irq_level); | ||
223 | } | 237 | } |
224 | 238 | ||
225 | /* Change the order of the noise shaper, 5th order is recommended above 32kHz */ | 239 | /* Change the order of the noise shaper, 5th order is recommended above 32kHz */ |
@@ -231,6 +245,8 @@ void wmcodec_set_nsorder(int order) | |||
231 | /* Note: Disable output before calling this function */ | 245 | /* Note: Disable output before calling this function */ |
232 | void wmcodec_set_sample_rate(int sampling_control) | 246 | void wmcodec_set_sample_rate(int sampling_control) |
233 | { | 247 | { |
248 | int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
249 | |||
234 | /**** We force 44.1KHz for now. ****/ | 250 | /**** We force 44.1KHz for now. ****/ |
235 | (void)sampling_control; | 251 | (void)sampling_control; |
236 | 252 | ||
@@ -248,6 +264,8 @@ void wmcodec_set_sample_rate(int sampling_control) | |||
248 | 264 | ||
249 | /* set srate */ | 265 | /* set srate */ |
250 | wm8758_write(SRATECTRL, (0 << 1)); | 266 | wm8758_write(SRATECTRL, (0 << 1)); |
267 | |||
268 | set_irq_level(old_irq_level); | ||
251 | } | 269 | } |
252 | 270 | ||
253 | void wmcodec_enable_recording(bool source_mic) | 271 | void wmcodec_enable_recording(bool source_mic) |