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.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index 7f96ee075a..fae8377c4b 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -35,7 +35,7 @@
35#endif 35#endif
36 36
37/* hacking into mpeg.c, recording is still there */ 37/* hacking into mpeg.c, recording is still there */
38#ifdef HAVE_MAS3587F 38#if CONFIG_HWCODEC == MAS3587F
39enum 39enum
40{ 40{
41 MPEG_DECODER, 41 MPEG_DECODER,
@@ -44,7 +44,7 @@ enum
44 44
45extern unsigned long shadow_7f1; 45extern unsigned long shadow_7f1;
46 46
47#endif /* #ifdef HAVE_MAS3587F */ 47#endif /* #ifdef MAS3587F */
48 48
49/**** globals ****/ 49/**** globals ****/
50 50
@@ -124,7 +124,7 @@ static const int steps[] =
124static const int minval[] = 124static const int minval[] =
125{ 125{
126 0, /* Volume */ 126 0, /* Volume */
127#ifdef HAVE_MAS3587F 127#if CONFIG_HWCODEC == MAS3587F
128 -12, /* Bass */ 128 -12, /* Bass */
129 -12, /* Treble */ 129 -12, /* Treble */
130#else 130#else
@@ -149,7 +149,7 @@ static const int minval[] =
149static const int maxval[] = 149static const int maxval[] =
150{ 150{
151 100, /* Volume */ 151 100, /* Volume */
152#ifdef HAVE_MAS3587F 152#if CONFIG_HWCODEC == MAS3587F
153 12, /* Bass */ 153 12, /* Bass */
154 12, /* Treble */ 154 12, /* Treble */
155#else 155#else
@@ -174,7 +174,7 @@ static const int maxval[] =
174static const int defaultval[] = 174static const int defaultval[] =
175{ 175{
176 70, /* Volume */ 176 70, /* Volume */
177#ifdef HAVE_MAS3587F 177#if CONFIG_HWCODEC == MAS3587F
178 6, /* Bass */ 178 6, /* Bass */
179 6, /* Treble */ 179 6, /* Treble */
180#else 180#else
@@ -238,7 +238,7 @@ static bool mpeg_is_initialized = false;
238 238
239unsigned long mas_version_code; 239unsigned long mas_version_code;
240 240
241#ifdef HAVE_MAS3507D 241#if CONFIG_HWCODEC == MAS3507D
242 242
243static const unsigned int bass_table[] = 243static const unsigned int bass_table[] =
244{ 244{
@@ -333,7 +333,7 @@ static const unsigned int prescale_table[] =
333 333
334bool dma_on; /* The DMA is active */ 334bool dma_on; /* The DMA is active */
335 335
336#ifdef HAVE_MAS3507D 336#if CONFIG_HWCODEC == MAS3507D
337static void mas_poll_start(int interval_in_ms) 337static void mas_poll_start(int interval_in_ms)
338{ 338{
339 unsigned int count; 339 unsigned int count;
@@ -393,7 +393,7 @@ static void postpone_dma_tick(void)
393#endif 393#endif
394 394
395 395
396#ifdef HAVE_MAS3587F 396#if CONFIG_HWCODEC == MAS3587F
397void demand_irq_enable(bool on) 397void demand_irq_enable(bool on)
398{ 398{
399 int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); 399 int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -408,7 +408,7 @@ void demand_irq_enable(bool on)
408 408
409 set_irq_level(oldlevel); 409 set_irq_level(oldlevel);
410} 410}
411#endif /* #ifdef HAVE_MAS3587F */ 411#endif /* #if CONFIG_HWCODEC == MAS3587F */
412 412
413 413
414void play_tick(void) 414void play_tick(void)
@@ -455,10 +455,10 @@ void IMIA1(void) /* Timer 1 interrupt */
455 if(playing) 455 if(playing)
456 play_tick(); 456 play_tick();
457 TSR1 &= ~0x01; 457 TSR1 &= ~0x01;
458#ifdef HAVE_MAS3587F 458#if CONFIG_HWCODEC == MAS3587F
459 /* Disable interrupt */ 459 /* Disable interrupt */
460 IPRC &= ~0x000f; 460 IPRC &= ~0x000f;
461#endif /* #ifdef HAVE_MAS3587F */ 461#endif /* #if CONFIG_HWCODEC == MAS3587F */
462} 462}
463 463
464#pragma interrupt 464#pragma interrupt
@@ -467,7 +467,7 @@ void IRQ6(void) /* PB14: MAS stop demand IRQ */
467 SCR0 &= ~0x80; 467 SCR0 &= ~0x80;
468} 468}
469 469
470#ifdef HAVE_MAS3587F 470#if CONFIG_HWCODEC == MAS3587F
471#pragma interrupt 471#pragma interrupt
472void IRQ3(void) /* PA15: MAS demand IRQ */ 472void IRQ3(void) /* PA15: MAS demand IRQ */
473{ 473{
@@ -479,7 +479,7 @@ void IRQ3(void) /* PA15: MAS demand IRQ */
479 else 479 else
480 postpone_dma_tick(); 480 postpone_dma_tick();
481} 481}
482#endif /* #ifdef HAVE_MAS3587F */ 482#endif /* #if CONFIG_HWCODEC == MAS3587F */
483 483
484static void setup_sci0(void) 484static void setup_sci0(void)
485{ 485{
@@ -519,7 +519,7 @@ static void setup_sci0(void)
519} 519}
520#endif /* SIMULATOR */ 520#endif /* SIMULATOR */
521 521
522#ifdef HAVE_MAS3587F 522#if CONFIG_HWCODEC == MAS3587F
523static void init_playback(void) 523static void init_playback(void)
524{ 524{
525 unsigned long val; 525 unsigned long val;
@@ -577,10 +577,10 @@ static void init_playback(void)
577 577
578 DEBUGF("MAS Decoding application started\n"); 578 DEBUGF("MAS Decoding application started\n");
579} 579}
580#endif /* #ifdef HAVE_MAS3587F */ 580#endif /* #if CONFIG_HWCODEC == MAS3587F */
581 581
582#ifndef SIMULATOR 582#ifndef SIMULATOR
583#ifdef HAVE_MAS3507D 583#if CONFIG_HWCODEC == MAS3507D
584int current_left_volume = 0; /* all values in tenth of dB */ 584int current_left_volume = 0; /* all values in tenth of dB */
585int current_right_volume = 0; /* all values in tenth of dB */ 585int current_right_volume = 0; /* all values in tenth of dB */
586int current_treble = 0; 586int current_treble = 0;
@@ -613,10 +613,10 @@ void set_prescaled_volume(void)
613 613
614 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); 614 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
615} 615}
616#endif /* HAVE_MAS3507D */ 616#endif /* MAS3507D */
617#endif /* !SIMULATOR */ 617#endif /* !SIMULATOR */
618 618
619#ifdef HAVE_MAS3587F 619#if CONFIG_HWCODEC == MAS3587F
620unsigned long mdb_shape_shadow = 0; 620unsigned long mdb_shape_shadow = 0;
621unsigned long loudness_shadow = 0; 621unsigned long loudness_shadow = 0;
622#endif 622#endif
@@ -626,7 +626,7 @@ void mpeg_sound_set(int setting, int value)
626#ifdef SIMULATOR 626#ifdef SIMULATOR
627 setting = value; 627 setting = value;
628#else 628#else
629#ifdef HAVE_MAS3507D 629#if CONFIG_HWCODEC == MAS3507D
630 int l, r; 630 int l, r;
631#else 631#else
632 int tmp; 632 int tmp;
@@ -638,7 +638,7 @@ void mpeg_sound_set(int setting, int value)
638 switch(setting) 638 switch(setting)
639 { 639 {
640 case SOUND_VOLUME: 640 case SOUND_VOLUME:
641#ifdef HAVE_MAS3587F 641#if CONFIG_HWCODEC == MAS3587F
642 tmp = 0x7f00 * value / 100; 642 tmp = 0x7f00 * value / 100;
643 mas_codec_writereg(0x10, tmp & 0xff00); 643 mas_codec_writereg(0x10, tmp & 0xff00);
644#else 644#else
@@ -671,7 +671,7 @@ void mpeg_sound_set(int setting, int value)
671 break; 671 break;
672 672
673 case SOUND_BALANCE: 673 case SOUND_BALANCE:
674#ifdef HAVE_MAS3587F 674#if CONFIG_HWCODEC == MAS3587F
675 tmp = ((value * 127 / 100) & 0xff) << 8; 675 tmp = ((value * 127 / 100) & 0xff) << 8;
676 mas_codec_writereg(0x11, tmp & 0xff00); 676 mas_codec_writereg(0x11, tmp & 0xff00);
677#else 677#else
@@ -680,7 +680,7 @@ void mpeg_sound_set(int setting, int value)
680 break; 680 break;
681 681
682 case SOUND_BASS: 682 case SOUND_BASS:
683#ifdef HAVE_MAS3587F 683#if CONFIG_HWCODEC == MAS3587F
684 tmp = ((value * 8) & 0xff) << 8; 684 tmp = ((value * 8) & 0xff) << 8;
685 mas_codec_writereg(0x14, tmp & 0xff00); 685 mas_codec_writereg(0x14, tmp & 0xff00);
686#else 686#else
@@ -691,7 +691,7 @@ void mpeg_sound_set(int setting, int value)
691 break; 691 break;
692 692
693 case SOUND_TREBLE: 693 case SOUND_TREBLE:
694#ifdef HAVE_MAS3587F 694#if CONFIG_HWCODEC == MAS3587F
695 tmp = ((value * 8) & 0xff) << 8; 695 tmp = ((value * 8) & 0xff) << 8;
696 mas_codec_writereg(0x15, tmp & 0xff00); 696 mas_codec_writereg(0x15, tmp & 0xff00);
697#else 697#else
@@ -701,7 +701,7 @@ void mpeg_sound_set(int setting, int value)
701#endif 701#endif
702 break; 702 break;
703 703
704#ifdef HAVE_MAS3587F 704#if CONFIG_HWCODEC == MAS3587F
705 case SOUND_LOUDNESS: 705 case SOUND_LOUDNESS:
706 loudness_shadow = (loudness_shadow & 0x04) | 706 loudness_shadow = (loudness_shadow & 0x04) |
707 (MAX(MIN(value * 4, 0x44), 0) << 8); 707 (MAX(MIN(value * 4, 0x44), 0) << 8);
@@ -771,7 +771,7 @@ void mpeg_sound_set(int setting, int value)
771 771
772int mpeg_val2phys(int setting, int value) 772int mpeg_val2phys(int setting, int value)
773{ 773{
774#ifdef HAVE_MAS3587F 774#if CONFIG_HWCODEC == MAS3587F
775 int result = 0; 775 int result = 0;
776 776
777 switch(setting) 777 switch(setting)
@@ -858,7 +858,7 @@ void mpeg_sound_channel_config(int configuration)
858 break; 858 break;
859 } 859 }
860 860
861#ifdef HAVE_MAS3587F 861#if CONFIG_HWCODEC == MAS3587F
862 mas_writemem(MAS_BANK_D0, 0x7fc, &val_ll, 1); /* LL */ 862 mas_writemem(MAS_BANK_D0, 0x7fc, &val_ll, 1); /* LL */
863 mas_writemem(MAS_BANK_D0, 0x7fd, &val_lr, 1); /* LR */ 863 mas_writemem(MAS_BANK_D0, 0x7fd, &val_lr, 1); /* LR */
864 mas_writemem(MAS_BANK_D0, 0x7fe, &val_rl, 1); /* RL */ 864 mas_writemem(MAS_BANK_D0, 0x7fe, &val_rl, 1); /* RL */
@@ -872,7 +872,7 @@ void mpeg_sound_channel_config(int configuration)
872#endif 872#endif
873} 873}
874 874
875#ifdef HAVE_MAS3587F 875#if CONFIG_HWCODEC == MAS3587F
876/* This function works by telling the decoder that we have another 876/* This function works by telling the decoder that we have another
877 crystal frequency than we actually have. It will adjust its internal 877 crystal frequency than we actually have. It will adjust its internal
878 parameters and the result is that the audio is played at another pitch. 878 parameters and the result is that the audio is played at another pitch.
@@ -918,7 +918,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
918 (void)mdb_enable; 918 (void)mdb_enable;
919 (void)superbass; 919 (void)superbass;
920#else 920#else
921#ifdef HAVE_MAS3507D 921#if CONFIG_HWCODEC == MAS3507D
922 unsigned long val; 922 unsigned long val;
923 (void)loudness; 923 (void)loudness;
924 (void)avc; 924 (void)avc;
@@ -932,7 +932,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
932 932
933 setup_sci0(); 933 setup_sci0();
934 934
935#ifdef HAVE_MAS3587F 935#if CONFIG_HWCODEC == MAS3587F
936 or_b(0x08, &PAIORH); /* output for /PR */ 936 or_b(0x08, &PAIORH); /* output for /PR */
937 init_playback(); 937 init_playback();
938 938
@@ -946,7 +946,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
946 dac_init(); 946 dac_init();
947#endif 947#endif
948 948
949#ifdef HAVE_MAS3507D 949#if CONFIG_HWCODEC == MAS3507D
950 and_b(~0x20, &PBDRL); 950 and_b(~0x20, &PBDRL);
951 sleep(HZ/5); 951 sleep(HZ/5);
952 or_b(0x20, &PBDRL); 952 or_b(0x20, &PBDRL);
@@ -992,7 +992,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
992 992
993#endif 993#endif
994 994
995#ifdef HAVE_MAS3507D 995#if CONFIG_HWCODEC == MAS3507D
996 mas_poll_start(1); 996 mas_poll_start(1);
997 997
998 mas_writereg(MAS_REG_KPRESCALE, 0xe9400); 998 mas_writereg(MAS_REG_KPRESCALE, 0xe9400);
@@ -1001,7 +1001,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
1001 mpeg_sound_channel_config(channel_config); 1001 mpeg_sound_channel_config(channel_config);
1002#endif 1002#endif
1003 1003
1004#ifdef HAVE_MAS3587F 1004#if CONFIG_HWCODEC == MAS3587F
1005 ICR &= ~0x0010; /* IRQ3 level sensitive */ 1005 ICR &= ~0x0010; /* IRQ3 level sensitive */
1006 PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */ 1006 PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */
1007#endif 1007#endif
@@ -1014,7 +1014,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
1014 mpeg_sound_set(SOUND_BALANCE, balance); 1014 mpeg_sound_set(SOUND_BALANCE, balance);
1015 mpeg_sound_set(SOUND_VOLUME, volume); 1015 mpeg_sound_set(SOUND_VOLUME, volume);
1016 1016
1017#ifdef HAVE_MAS3587F 1017#if CONFIG_HWCODEC == MAS3587F
1018 mpeg_sound_channel_config(channel_config); 1018 mpeg_sound_channel_config(channel_config);
1019 mpeg_sound_set(SOUND_LOUDNESS, loudness); 1019 mpeg_sound_set(SOUND_LOUDNESS, loudness);
1020 mpeg_sound_set(SOUND_AVC, avc); 1020 mpeg_sound_set(SOUND_AVC, avc);
@@ -1034,12 +1034,12 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
1034void mp3_shutdown(void) 1034void mp3_shutdown(void)
1035{ 1035{
1036#ifndef SIMULATOR 1036#ifndef SIMULATOR
1037#ifdef HAVE_MAS3587F 1037#if CONFIG_HWCODEC == MAS3587F
1038 unsigned long val = 1; 1038 unsigned long val = 1;
1039 mas_writemem(MAS_BANK_D0, 0x7f9, &val, 1); /* Mute */ 1039 mas_writemem(MAS_BANK_D0, 0x7f9, &val, 1); /* Mute */
1040#endif 1040#endif
1041 1041
1042#ifdef HAVE_MAS3507D 1042#if CONFIG_HWCODEC == MAS3507D
1043 dac_volume(0, 0, false); 1043 dac_volume(0, 0, false);
1044#endif 1044#endif
1045 1045
@@ -1052,7 +1052,7 @@ void mp3_shutdown(void)
1052 1052
1053void mp3_play_init(void) 1053void mp3_play_init(void)
1054{ 1054{
1055#ifdef HAVE_MAS3587F 1055#if CONFIG_HWCODEC == MAS3587F
1056 init_playback(); 1056 init_playback();
1057#endif 1057#endif
1058 playing = false; 1058 playing = false;
@@ -1081,7 +1081,7 @@ void mp3_play_data(const unsigned char* start, int size,
1081 1081
1082 CHCR3 |= 0x0001; /* Enable DMA IRQ */ 1082 CHCR3 |= 0x0001; /* Enable DMA IRQ */
1083 1083
1084#ifdef HAVE_MAS3587F 1084#if CONFIG_HWCODEC == MAS3587F
1085 demand_irq_enable(true); 1085 demand_irq_enable(true);
1086#endif 1086#endif
1087} 1087}
@@ -1107,7 +1107,7 @@ void mp3_play_stop(void)
1107 playing = false; 1107 playing = false;
1108 mp3_play_pause(false); 1108 mp3_play_pause(false);
1109 CHCR3 &= ~0x0001; /* Disable the DMA interrupt */ 1109 CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
1110#ifdef HAVE_MAS3587F 1110#if CONFIG_HWCODEC == MAS3587F
1111 demand_irq_enable(false); 1111 demand_irq_enable(false);
1112#endif 1112#endif
1113} 1113}