summaryrefslogtreecommitdiff
path: root/firmware/mp3_playback.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/mp3_playback.c')
-rw-r--r--firmware/mp3_playback.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index 3a2fdb4f1a..b7114007b9 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -36,7 +36,7 @@
36#endif 36#endif
37 37
38/* hacking into mpeg.c, recording is still there */ 38/* hacking into mpeg.c, recording is still there */
39#if CONFIG_HWCODEC == MAS3587F 39#if CONFIG_CODEC == MAS3587F
40enum 40enum
41{ 41{
42 MPEG_DECODER, 42 MPEG_DECODER,
@@ -44,7 +44,7 @@ enum
44} mpeg_mode; 44} mpeg_mode;
45#endif /* #ifdef MAS3587F */ 45#endif /* #ifdef MAS3587F */
46 46
47#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 47#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
48extern unsigned long shadow_io_control_main; 48extern unsigned long shadow_io_control_main;
49extern unsigned shadow_codec_reg0; 49extern unsigned shadow_codec_reg0;
50#endif 50#endif
@@ -72,14 +72,14 @@ static void (*callback_for_more)(unsigned char**, int*);
72bool audio_is_initialized = false; 72bool audio_is_initialized = false;
73#endif 73#endif
74 74
75#if CONFIG_HWCODEC != MASNONE 75#if CONFIG_CODEC != SWCODEC
76/* FIX: this code pretty much assumes a MAS */ 76/* FIX: this code pretty much assumes a MAS */
77 77
78#ifndef SIMULATOR 78#ifndef SIMULATOR
79 79
80unsigned long mas_version_code; 80unsigned long mas_version_code;
81 81
82#if CONFIG_HWCODEC == MAS3507D 82#if CONFIG_CODEC == MAS3507D
83static void mas_poll_start(void) 83static void mas_poll_start(void)
84{ 84{
85 unsigned int count; 85 unsigned int count;
@@ -104,7 +104,7 @@ static void mas_poll_start(void)
104 104
105 TSTR |= 0x02; /* Start timer 1 */ 105 TSTR |= 0x02; /* Start timer 1 */
106} 106}
107#elif CONFIG_HWCODEC != MASNONE 107#elif CONFIG_CODEC != SWCODEC
108static void postpone_dma_tick(void) 108static void postpone_dma_tick(void)
109{ 109{
110 unsigned int count; 110 unsigned int count;
@@ -132,7 +132,7 @@ static void postpone_dma_tick(void)
132#endif 132#endif
133 133
134 134
135#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 135#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
136void demand_irq_enable(bool on) 136void demand_irq_enable(bool on)
137{ 137{
138 int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); 138 int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -147,7 +147,7 @@ void demand_irq_enable(bool on)
147 147
148 set_irq_level(oldlevel); 148 set_irq_level(oldlevel);
149} 149}
150#endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */ 150#endif /* #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
151 151
152 152
153void play_tick(void) 153void play_tick(void)
@@ -194,7 +194,7 @@ void IMIA1(void) /* Timer 1 interrupt */
194 if(playing) 194 if(playing)
195 play_tick(); 195 play_tick();
196 TSR1 &= ~0x01; 196 TSR1 &= ~0x01;
197#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 197#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
198 /* Disable interrupt */ 198 /* Disable interrupt */
199 IPRC &= ~0x000f; 199 IPRC &= ~0x000f;
200#endif 200#endif
@@ -206,21 +206,21 @@ void IRQ6(void) /* PB14: MAS stop demand IRQ */
206 SCR0 &= ~0x80; 206 SCR0 &= ~0x80;
207} 207}
208 208
209#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 209#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
210#pragma interrupt 210#pragma interrupt
211void IRQ3(void) /* PA15: MAS demand IRQ */ 211void IRQ3(void) /* PA15: MAS demand IRQ */
212{ 212{
213 /* Begin with setting the IRQ to edge sensitive */ 213 /* Begin with setting the IRQ to edge sensitive */
214 ICR |= 0x0010; 214 ICR |= 0x0010;
215 215
216#if CONFIG_HWCODEC == MAS3587F 216#if CONFIG_CODEC == MAS3587F
217 if(mpeg_mode == MPEG_ENCODER) 217 if(mpeg_mode == MPEG_ENCODER)
218 rec_tick(); 218 rec_tick();
219 else 219 else
220#endif 220#endif
221 postpone_dma_tick(); 221 postpone_dma_tick();
222} 222}
223#endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */ 223#endif /* #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
224 224
225static void setup_sci0(void) 225static void setup_sci0(void)
226{ 226{
@@ -260,7 +260,7 @@ static void setup_sci0(void)
260} 260}
261#endif /* SIMULATOR */ 261#endif /* SIMULATOR */
262 262
263#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 263#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
264static void init_playback(void) 264static void init_playback(void)
265{ 265{
266 unsigned long val; 266 unsigned long val;
@@ -310,7 +310,7 @@ static void init_playback(void)
310 mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1); 310 mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1);
311 } while((val & 0x0c) != 0x0c); 311 } while((val & 0x0c) != 0x0c);
312 312
313#if CONFIG_HWCODEC == MAS3587F 313#if CONFIG_CODEC == MAS3587F
314 mpeg_mode = MPEG_DECODER; 314 mpeg_mode = MPEG_DECODER;
315#endif 315#endif
316 316
@@ -322,7 +322,7 @@ static void init_playback(void)
322 322
323 DEBUGF("MAS Decoding application started\n"); 323 DEBUGF("MAS Decoding application started\n");
324} 324}
325#endif /* #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) */ 325#endif /* #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
326 326
327void mp3_init(int volume, int bass, int treble, int balance, int loudness, 327void mp3_init(int volume, int bass, int treble, int balance, int loudness,
328 int avc, int channel_config, int stereo_width, 328 int avc, int channel_config, int stereo_width,
@@ -346,7 +346,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
346 (void)mdb_enable; 346 (void)mdb_enable;
347 (void)superbass; 347 (void)superbass;
348#else 348#else
349#if CONFIG_HWCODEC == MAS3507D 349#if CONFIG_CODEC == MAS3507D
350 unsigned long val; 350 unsigned long val;
351 (void)loudness; 351 (void)loudness;
352 (void)avc; 352 (void)avc;
@@ -365,9 +365,9 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
365 or_b(0x01, &PBIORH); /* output for PB8 */ 365 or_b(0x01, &PBIORH); /* output for PB8 */
366#endif 366#endif
367 367
368#if CONFIG_HWCODEC == MAS3507D 368#if CONFIG_CODEC == MAS3507D
369 mas_reset(); 369 mas_reset();
370#elif CONFIG_HWCODEC == MAS3587F 370#elif CONFIG_CODEC == MAS3587F
371 or_b(0x08, &PAIORH); /* output for /PR */ 371 or_b(0x08, &PAIORH); /* output for /PR */
372 init_playback(); 372 init_playback();
373 373
@@ -375,7 +375,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
375 DEBUGF("MAS3587 derivate %d, version %c%d\n", 375 DEBUGF("MAS3587 derivate %d, version %c%d\n",
376 (mas_version_code & 0xf000) >> 12, 376 (mas_version_code & 0xf000) >> 12,
377 'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff); 377 'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff);
378#elif CONFIG_HWCODEC == MAS3539F 378#elif CONFIG_CODEC == MAS3539F
379 or_b(0x08, &PAIORH); /* output for /PR */ 379 or_b(0x08, &PAIORH); /* output for /PR */
380 init_playback(); 380 init_playback();
381 381
@@ -389,7 +389,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
389 dac_init(); 389 dac_init();
390#endif 390#endif
391 391
392#if CONFIG_HWCODEC == MAS3507D 392#if CONFIG_CODEC == MAS3507D
393 /* set IRQ6 to edge detect */ 393 /* set IRQ6 to edge detect */
394 ICR |= 0x02; 394 ICR |= 0x02;
395 395
@@ -430,14 +430,14 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
430 430
431#endif 431#endif
432 432
433#if CONFIG_HWCODEC == MAS3507D 433#if CONFIG_CODEC == MAS3507D
434 mas_poll_start(); 434 mas_poll_start();
435 435
436 mas_writereg(MAS_REG_KPRESCALE, 0xe9400); 436 mas_writereg(MAS_REG_KPRESCALE, 0xe9400);
437 dac_enable(true); 437 dac_enable(true);
438#endif 438#endif
439 439
440#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 440#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
441 ICR &= ~0x0010; /* IRQ3 level sensitive */ 441 ICR &= ~0x0010; /* IRQ3 level sensitive */
442 PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */ 442 PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */
443#endif 443#endif
@@ -452,7 +452,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
452 sound_set(SOUND_CHANNELS, channel_config); 452 sound_set(SOUND_CHANNELS, channel_config);
453 sound_set(SOUND_STEREO_WIDTH, stereo_width); 453 sound_set(SOUND_STEREO_WIDTH, stereo_width);
454 454
455#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 455#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
456 sound_set(SOUND_LOUDNESS, loudness); 456 sound_set(SOUND_LOUDNESS, loudness);
457 sound_set(SOUND_AVC, avc); 457 sound_set(SOUND_AVC, avc);
458 sound_set(SOUND_MDB_STRENGTH, mdb_strength); 458 sound_set(SOUND_MDB_STRENGTH, mdb_strength);
@@ -471,12 +471,12 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
471void mp3_shutdown(void) 471void mp3_shutdown(void)
472{ 472{
473#ifndef SIMULATOR 473#ifndef SIMULATOR
474#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 474#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
475 unsigned long val = 1; 475 unsigned long val = 1;
476 mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &val, 1); /* Mute */ 476 mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &val, 1); /* Mute */
477#endif 477#endif
478 478
479#if CONFIG_HWCODEC == MAS3507D 479#if CONFIG_CODEC == MAS3507D
480 dac_volume(0, 0, false); 480 dac_volume(0, 0, false);
481#endif 481#endif
482 482
@@ -489,7 +489,7 @@ void mp3_shutdown(void)
489 489
490void mp3_play_init(void) 490void mp3_play_init(void)
491{ 491{
492#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 492#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
493 init_playback(); 493 init_playback();
494#endif 494#endif
495 playing = false; 495 playing = false;
@@ -518,7 +518,7 @@ void mp3_play_data(const unsigned char* start, int size,
518 518
519 CHCR3 |= 0x0001; /* Enable DMA IRQ */ 519 CHCR3 |= 0x0001; /* Enable DMA IRQ */
520 520
521#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 521#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
522 demand_irq_enable(true); 522 demand_irq_enable(true);
523#endif 523#endif
524} 524}
@@ -557,7 +557,7 @@ void mp3_play_stop(void)
557 playing = false; 557 playing = false;
558 mp3_play_pause(false); 558 mp3_play_pause(false);
559 CHCR3 &= ~0x0001; /* Disable the DMA interrupt */ 559 CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
560#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) 560#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
561 demand_irq_enable(false); 561 demand_irq_enable(false);
562#endif 562#endif
563} 563}
@@ -591,7 +591,7 @@ unsigned char* mp3_get_pos(void)
591 591
592#endif /* #ifndef SIMULATOR */ 592#endif /* #ifndef SIMULATOR */
593 593
594#else /* CONFIG_HWCODEC != MASNONE */ 594#else /* CONFIG_CODEC != SWCODEC */
595void mp3_init(int volume, int bass, int treble, int balance, int loudness, 595void mp3_init(int volume, int bass, int treble, int balance, int loudness,
596 int avc, int channel_config, int stereo_width, 596 int avc, int channel_config, int stereo_width,
597 int mdb_strength, int mdb_harmonics, 597 int mdb_strength, int mdb_harmonics,
@@ -651,4 +651,4 @@ bool mp3_is_playing(void)
651 return playing; 651 return playing;
652} 652}
653 653
654#endif /* CONFIG_HWCODEC == MASNONE */ 654#endif /* CONFIG_CODEC == SWCODEC */