diff options
Diffstat (limited to 'firmware/pcm_playback.c')
-rw-r--r-- | firmware/pcm_playback.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c index 17350edfb5..c79902845a 100644 --- a/firmware/pcm_playback.c +++ b/firmware/pcm_playback.c | |||
@@ -24,7 +24,11 @@ | |||
24 | #ifndef SIMULATOR | 24 | #ifndef SIMULATOR |
25 | #include "cpu.h" | 25 | #include "cpu.h" |
26 | #include "i2c.h" | 26 | #include "i2c.h" |
27 | #if defined(HAVE_UDA1380) | ||
27 | #include "uda1380.h" | 28 | #include "uda1380.h" |
29 | #elif defined(HAVE_TLV320) | ||
30 | #include "tlv320.h" | ||
31 | #endif | ||
28 | #include "system.h" | 32 | #include "system.h" |
29 | #endif | 33 | #endif |
30 | #include "logf.h" | 34 | #include "logf.h" |
@@ -181,13 +185,18 @@ void pcm_play_data(void (*get_more)(unsigned char** start, long* size)) | |||
181 | { | 185 | { |
182 | unsigned char *start; | 186 | unsigned char *start; |
183 | long size; | 187 | long size; |
184 | 188 | ||
185 | callback_for_more = get_more; | 189 | callback_for_more = get_more; |
186 | 190 | ||
187 | get_more((unsigned char **)&start, (long *)&size); | 191 | get_more((unsigned char **)&start, (long *)&size); |
188 | get_more(&next_start, &next_size); | 192 | get_more(&next_start, &next_size); |
189 | dma_start(start, size); | 193 | dma_start(start, size); |
194 | |||
195 | #if defined(HAVE_UDA1380) | ||
190 | uda1380_mute(false); | 196 | uda1380_mute(false); |
197 | #elif defined(HAVE_TLV320) | ||
198 | tlv320_mute(false); | ||
199 | #endif | ||
191 | } | 200 | } |
192 | 201 | ||
193 | long pcm_get_bytes_waiting(void) | 202 | long pcm_get_bytes_waiting(void) |
@@ -198,7 +207,12 @@ long pcm_get_bytes_waiting(void) | |||
198 | void pcm_play_stop(void) | 207 | void pcm_play_stop(void) |
199 | { | 208 | { |
200 | if (pcm_playing) { | 209 | if (pcm_playing) { |
210 | |||
211 | #if defined(HAVE_UDA1380) | ||
201 | uda1380_mute(true); | 212 | uda1380_mute(true); |
213 | #elif defined(HAVE_TLV320) | ||
214 | tlv320_mute(true); | ||
215 | #endif | ||
202 | dma_stop(); | 216 | dma_stop(); |
203 | } | 217 | } |
204 | } | 218 | } |
@@ -216,14 +230,23 @@ void pcm_play_pause(bool play) | |||
216 | IIS2CONFIG = (pcm_freq << 12) | 0x300 | 4 << 2; | 230 | IIS2CONFIG = (pcm_freq << 12) | 0x300 | 4 << 2; |
217 | EBU1CONFIG = (7 << 12) | (3 << 8) | (1 << 5) | (5 << 2); | 231 | EBU1CONFIG = (7 << 12) | (3 << 8) | (1 << 5) | (5 << 2); |
218 | DCR0 |= DMA_EEXT | DMA_START; | 232 | DCR0 |= DMA_EEXT | DMA_START; |
219 | 233 | ||
234 | #if defined(HAVE_UDA1380) | ||
220 | uda1380_mute(false); | 235 | uda1380_mute(false); |
236 | #elif defined(HAVE_TLV320) | ||
237 | tlv320_mute(false); | ||
238 | #endif | ||
221 | } | 239 | } |
222 | else if(!pcm_paused && !play) | 240 | else if(!pcm_paused && !play) |
223 | { | 241 | { |
224 | logf("pause"); | 242 | logf("pause"); |
243 | |||
244 | #if defined(HAVE_UDA1380) | ||
225 | uda1380_mute(true); | 245 | uda1380_mute(true); |
226 | 246 | #elif defined(HAVE_TLV320) | |
247 | tlv320_mute(true); | ||
248 | #endif | ||
249 | |||
227 | /* Disable DMA peripheral request. */ | 250 | /* Disable DMA peripheral request. */ |
228 | DCR0 &= ~DMA_EEXT; | 251 | DCR0 &= ~DMA_EEXT; |
229 | IIS2CONFIG = 0x800; | 252 | IIS2CONFIG = 0x800; |
@@ -250,7 +273,7 @@ void DMA0(void) | |||
250 | 273 | ||
251 | DSR0 = 1; /* Clear interrupt */ | 274 | DSR0 = 1; /* Clear interrupt */ |
252 | DCR0 &= ~DMA_EEXT; | 275 | DCR0 &= ~DMA_EEXT; |
253 | 276 | ||
254 | /* Stop on error */ | 277 | /* Stop on error */ |
255 | if(res & 0x70) | 278 | if(res & 0x70) |
256 | { | 279 | { |
@@ -274,7 +297,7 @@ void DMA0(void) | |||
274 | logf("DMA No Data:0x%04x", res); | 297 | logf("DMA No Data:0x%04x", res); |
275 | } | 298 | } |
276 | } | 299 | } |
277 | 300 | ||
278 | IPR |= (1<<14); /* Clear pending interrupt request */ | 301 | IPR |= (1<<14); /* Clear pending interrupt request */ |
279 | } | 302 | } |
280 | 303 | ||
@@ -282,8 +305,12 @@ void pcm_init(void) | |||
282 | { | 305 | { |
283 | pcm_playing = false; | 306 | pcm_playing = false; |
284 | pcm_paused = false; | 307 | pcm_paused = false; |
285 | 308 | ||
309 | #if defined(HAVE_UDA1380) | ||
286 | uda1380_init(); | 310 | uda1380_init(); |
311 | #elif defined(HAVE_TLV320) | ||
312 | tlv320_init(); | ||
313 | #endif | ||
287 | 314 | ||
288 | BUSMASTER_CTRL = 0x81; /* PARK[1,0]=10 + BCR24BIT */ | 315 | BUSMASTER_CTRL = 0x81; /* PARK[1,0]=10 + BCR24BIT */ |
289 | DIVR0 = 54; /* DMA0 is mapped into vector 54 in system.c */ | 316 | DIVR0 = 54; /* DMA0 is mapped into vector 54 in system.c */ |
@@ -292,18 +319,25 @@ void pcm_init(void) | |||
292 | 319 | ||
293 | /* Reset the audio FIFO */ | 320 | /* Reset the audio FIFO */ |
294 | IIS2CONFIG = 0x800; | 321 | IIS2CONFIG = 0x800; |
295 | 322 | ||
296 | /* Enable interrupt at level 7, priority 0 */ | 323 | /* Enable interrupt at level 7, priority 0 */ |
297 | ICR4 = (ICR4 & 0xffff00ff) | 0x00001c00; | 324 | ICR4 = (ICR4 & 0xffff00ff) | 0x00001c00; |
298 | IMR &= ~(1<<14); /* bit 14 is DMA0 */ | 325 | IMR &= ~(1<<14); /* bit 14 is DMA0 */ |
299 | 326 | ||
300 | pcm_set_frequency(44100); | 327 | pcm_set_frequency(44100); |
301 | 328 | ||
302 | /* Turn on headphone power with audio output muted. */ | 329 | /* Turn on headphone power with audio output muted. */ |
330 | #if defined(HAVE_UDA1380) | ||
303 | uda1380_mute(true); | 331 | uda1380_mute(true); |
332 | #elif defined(HAVE_TLV320) | ||
333 | tlv320_mute(true); | ||
334 | #endif | ||
304 | sleep(HZ/4); | 335 | sleep(HZ/4); |
336 | #if defined(HAVE_UDA1380) | ||
305 | uda1380_enable_output(true); | 337 | uda1380_enable_output(true); |
306 | 338 | #elif defined(HAVE_TLV320) | |
339 | tlv320_enable_output(true); | ||
340 | #endif | ||
307 | /* Call dma_stop to initialize everything. */ | 341 | /* Call dma_stop to initialize everything. */ |
308 | dma_stop(); | 342 | dma_stop(); |
309 | } | 343 | } |