summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/drivers/wm8731l.c52
-rw-r--r--firmware/export/config-ipodmini.h4
-rwxr-xr-xfirmware/export/config-ipodmini2g.h6
-rw-r--r--firmware/pcm_playback.c17
-rw-r--r--firmware/sound.c36
6 files changed, 87 insertions, 30 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index d145176145..4b2e63d378 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -183,7 +183,7 @@ drivers/uda1380.c
183drivers/wm8975.c 183drivers/wm8975.c
184#elif defined(HAVE_WM8758) && !defined(SIMULATOR) 184#elif defined(HAVE_WM8758) && !defined(SIMULATOR)
185drivers/wm8758.c 185drivers/wm8758.c
186#elif defined(HAVE_WM8731) && !defined(SIMULATOR) 186#elif (defined(HAVE_WM8731) || defined(HAVE_WM8721)) && !defined(SIMULATOR)
187drivers/wm8731l.c 187drivers/wm8731l.c
188#elif defined(HAVE_TLV320) && !defined(SIMULATOR) 188#elif defined(HAVE_TLV320) && !defined(SIMULATOR)
189drivers/tlv320.c 189drivers/tlv320.c
diff --git a/firmware/drivers/wm8731l.c b/firmware/drivers/wm8731l.c
index 990ad0ebbc..52d8d1e404 100644
--- a/firmware/drivers/wm8731l.c
+++ b/firmware/drivers/wm8731l.c
@@ -89,6 +89,27 @@ static void codec_set_active(int active)
89 */ 89 */
90static void i2s_reset(void) 90static void i2s_reset(void)
91{ 91{
92#if CONFIG_CPU == PP5020
93 /* I2S soft reset */
94 outl(inl(0x70002800) | 0x80000000, 0x70002800);
95 outl(inl(0x70002800) & ~0x80000000, 0x70002800);
96
97 /* BIT.FORMAT [11:10] = I2S (default) */
98 outl(inl(0x70002800) & ~0xc00, 0x70002800);
99 /* BIT.SIZE [9:8] = 16bit (default) */
100 outl(inl(0x70002800) & ~0x300, 0x70002800);
101
102 /* FIFO.FORMAT [6:4] = 32 bit LSB */
103 /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */
104 outl(inl(0x70002800) | 0x30, 0x70002800);
105
106 /* RX_ATN_LVL=1 == when 12 slots full */
107 /* TX_ATN_LVL=1 == when 12 slots empty */
108 outl(inl(0x7000280c) | 0x33, 0x7000280c);
109
110 /* Rx.CLR = 1, TX.CLR = 1 */
111 outl(inl(0x7000280c) | 0x1100, 0x7000280c);
112#elif CONFIG_CPU == PP5002
92 /* I2S device reset */ 113 /* I2S device reset */
93 outl(inl(0xcf005030) | 0x80, 0xcf005030); 114 outl(inl(0xcf005030) | 0x80, 0xcf005030);
94 outl(inl(0xcf005030) & ~0x80, 0xcf005030); 115 outl(inl(0xcf005030) & ~0x80, 0xcf005030);
@@ -102,6 +123,7 @@ static void i2s_reset(void)
102 123
103 /* reset DAC and ADC fifo */ 124 /* reset DAC and ADC fifo */
104 outl(inl(0xc000251c) | 0x30000, 0xc000251c); 125 outl(inl(0xc000251c) | 0x30000, 0xc000251c);
126#endif
105} 127}
106 128
107/* 129/*
@@ -112,6 +134,27 @@ int wmcodec_init(void) {
112 /* reset I2C */ 134 /* reset I2C */
113 i2c_init(); 135 i2c_init();
114 136
137#if CONFIG_CPU == PP5020
138 /* normal outputs for CDI and I2S pin groups */
139 outl(inl(0x70000020) & ~0x300, 0x70000020);
140
141 /*mini2?*/
142 outl(inl(0x70000010) & ~0x3000000, 0x70000010);
143 /*mini2?*/
144
145 /* device reset */
146 outl(inl(0x60006004) | 0x800, 0x60006004);
147 outl(inl(0x60006004) & ~0x800, 0x60006004);
148
149 /* device enable */
150 outl(inl(0x6000600C) | 0x807, 0x6000600C);
151
152 /* enable external dev clock clocks */
153 outl(inl(0x6000600c) | 0x2, 0x6000600c);
154
155 /* external dev clock to 24MHz */
156 outl(inl(0x70000018) & ~0xc, 0x70000018);
157#else
115 /* device reset */ 158 /* device reset */
116 outl(inl(0xcf005030) | 0x80, 0xcf005030); 159 outl(inl(0xcf005030) | 0x80, 0xcf005030);
117 outl(inl(0xcf005030) & ~0x80, 0xcf005030); 160 outl(inl(0xcf005030) & ~0x80, 0xcf005030);
@@ -135,6 +178,7 @@ int wmcodec_init(void) {
135 outl(inl(0xcf000008) | 0x8, 0xcf000008); 178 outl(inl(0xcf000008) | 0x8, 0xcf000008);
136 outl(inl(0xcf000018) | 0x8, 0xcf000018); 179 outl(inl(0xcf000018) | 0x8, 0xcf000018);
137 outl(inl(0xcf000028) & ~0x8, 0xcf000028); 180 outl(inl(0xcf000028) & ~0x8, 0xcf000028);
181#endif
138 182
139 return 0; 183 return 0;
140} 184}
@@ -142,7 +186,7 @@ int wmcodec_init(void) {
142/* Silently enable / disable audio output */ 186/* Silently enable / disable audio output */
143void wmcodec_enable_output(bool enable) 187void wmcodec_enable_output(bool enable)
144{ 188{
145 if (enable) 189 if (enable)
146 { 190 {
147 /* reset the I2S controller into known state */ 191 /* reset the I2S controller into known state */
148 i2s_reset(); 192 i2s_reset();
@@ -151,9 +195,13 @@ void wmcodec_enable_output(bool enable)
151 195
152 codec_set_active(0x0); 196 codec_set_active(0x0);
153 197
198#ifdef HAVE_WM8721
154 /* DACSEL=1 */ 199 /* DACSEL=1 */
155 /* BYPASS=1 */ 200 wm8731_write(0x4, 0x10);
201#elif defined HAVE_WM8731
202 /* DACSEL=1, BYPASS=1 */
156 wm8731_write(0x4, 0x18); 203 wm8731_write(0x4, 0x18);
204#endif
157 205
158 /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */ 206 /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
159 wm8731_write(PWRMGMT, 0x67); 207 wm8731_write(PWRMGMT, 0x67);
diff --git a/firmware/export/config-ipodmini.h b/firmware/export/config-ipodmini.h
index ea3f4e5c41..b4e909ce07 100644
--- a/firmware/export/config-ipodmini.h
+++ b/firmware/export/config-ipodmini.h
@@ -40,8 +40,8 @@
40/* The number of bytes reserved for loadable plugins */ 40/* The number of bytes reserved for loadable plugins */
41#define PLUGIN_BUFFER_SIZE 0x80000 41#define PLUGIN_BUFFER_SIZE 0x80000
42 42
43/* Define this if you have the WM8975 audio codec */ 43/* Define this if you have the WM8721 audio codec */
44#define HAVE_WM8975 44#define HAVE_WM8721 /* actually WM8731 but no recording */
45 45
46/* Define this for LCD backlight available */ 46/* Define this for LCD backlight available */
47#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */ 47#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */
diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h
index 60d812f8d7..83192cc627 100755
--- a/firmware/export/config-ipodmini2g.h
+++ b/firmware/export/config-ipodmini2g.h
@@ -6,7 +6,7 @@
6#define IPOD_ARCH 1 6#define IPOD_ARCH 1
7 7
8/* For Rolo and boot loader */ 8/* For Rolo and boot loader */
9#define MODEL_NUMBER 11 9#define MODEL_NUMBER 11
10 10
11/* define this if you have recording possibility */ 11/* define this if you have recording possibility */
12/*#define HAVE_RECORDING 1*/ 12/*#define HAVE_RECORDING 1*/
@@ -40,8 +40,8 @@
40/* The number of bytes reserved for loadable plugins */ 40/* The number of bytes reserved for loadable plugins */
41#define PLUGIN_BUFFER_SIZE 0x80000 41#define PLUGIN_BUFFER_SIZE 0x80000
42 42
43/* Define this if you have the WM8975 audio codec */ 43/* Define this if you have the WM8721 audio codec */
44#define HAVE_WM8975 44#define HAVE_WM8721 /* actually WM8731 but no recording */
45 45
46/* Define this for LCD backlight available */ 46/* Define this for LCD backlight available */
47#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */ 47#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */
diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c
index 9e28891e6d..d6dc41cdde 100644
--- a/firmware/pcm_playback.c
+++ b/firmware/pcm_playback.c
@@ -31,7 +31,7 @@
31#include "wm8758.h" 31#include "wm8758.h"
32#elif defined(HAVE_TLV320) 32#elif defined(HAVE_TLV320)
33#include "tlv320.h" 33#include "tlv320.h"
34#elif defined(HAVE_WM8731) 34#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
35#include "wm8731l.h" 35#include "wm8731l.h"
36#endif 36#endif
37#include "system.h" 37#include "system.h"
@@ -237,7 +237,8 @@ void pcm_init(void)
237 dma_stop(); 237 dma_stop();
238} 238}
239 239
240#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 240#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
241 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
241 242
242/* We need to unify this code with the uda1380 code as much as possible, but 243/* We need to unify this code with the uda1380 code as much as possible, but
243 we will keep it separate during early development. 244 we will keep it separate during early development.
@@ -522,7 +523,8 @@ void pcm_mute(bool mute)
522{ 523{
523#ifdef HAVE_UDA1380 524#ifdef HAVE_UDA1380
524 uda1380_mute(mute); 525 uda1380_mute(mute);
525#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 526#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
527 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
526 wmcodec_mute(mute); 528 wmcodec_mute(mute);
527#elif defined(HAVE_TLV320) 529#elif defined(HAVE_TLV320)
528 tlv320_mute(mute); 530 tlv320_mute(mute);
@@ -557,7 +559,8 @@ void pcm_play_pause(bool play)
557 EBU1CONFIG = EBU_DEFPARM; 559 EBU1CONFIG = EBU_DEFPARM;
558#endif 560#endif
559 DCR0 |= DMA_EEXT | DMA_START; 561 DCR0 |= DMA_EEXT | DMA_START;
560#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 562#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
563 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
561 /* Enable the FIFO and fill it */ 564 /* Enable the FIFO and fill it */
562 565
563 enable_fiq(); 566 enable_fiq();
@@ -616,7 +619,8 @@ void pcm_play_pause(bool play)
616#ifdef HAVE_SPDIF_OUT 619#ifdef HAVE_SPDIF_OUT
617 EBU1CONFIG = IIS_RESET | EBU_DEFPARM; 620 EBU1CONFIG = IIS_RESET | EBU_DEFPARM;
618#endif 621#endif
619#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 622#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
623 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
620#if CONFIG_CPU == PP5020 624#if CONFIG_CPU == PP5020
621 /* Disable the interrupt */ 625 /* Disable the interrupt */
622 IISCONFIG &= ~0x2; 626 IISCONFIG &= ~0x2;
@@ -672,7 +676,8 @@ void pcm_calculate_peaks(int *left, int *right)
672#ifdef CPU_COLDFIRE 676#ifdef CPU_COLDFIRE
673 size_t samples = (BCR0 & 0xffffff) / 4; 677 size_t samples = (BCR0 & 0xffffff) / 4;
674 addr = (short *) (SAR0 & ~3); 678 addr = (short *) (SAR0 & ~3);
675#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 679#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
680 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
676 size_t samples = p_size / 4; 681 size_t samples = p_size / 4;
677 addr = p; 682 addr = p;
678#endif 683#endif
diff --git a/firmware/sound.c b/firmware/sound.c
index 9a3e9d456a..e682d583ae 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -30,7 +30,7 @@
30#include "wm8975.h" 30#include "wm8975.h"
31#elif defined(HAVE_WM8758) 31#elif defined(HAVE_WM8758)
32#include "wm8758.h" 32#include "wm8758.h"
33#elif defined(HAVE_WM8731) 33#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
34#include "wm8731l.h" 34#include "wm8731l.h"
35#elif defined(HAVE_TLV320) 35#elif defined(HAVE_TLV320)
36#include "tlv320.h" 36#include "tlv320.h"
@@ -81,7 +81,7 @@ static const struct sound_settings_info sound_settings_table[] = {
81 [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25, sound_set_volume}, 81 [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25, sound_set_volume},
82 [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, 82 [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
83 [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, 83 [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble},
84#elif defined(HAVE_WM8731) 84#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
85 [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, 85 [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume},
86 [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, 86 [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
87 [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, 87 [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble},
@@ -380,7 +380,7 @@ static int tenthdb2mixer(int db)
380 return -db * 2 / 5; 380 return -db * 2 / 5;
381} 381}
382 382
383#elif defined(HAVE_WM8731) 383#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
384/* volume/balance/treble/bass interdependency */ 384/* volume/balance/treble/bass interdependency */
385#define VOLUME_MIN -730 385#define VOLUME_MIN -730
386#define VOLUME_MAX 60 386#define VOLUME_MAX 60
@@ -416,9 +416,9 @@ static int tenthdb2mixer(int db)
416 416
417#endif 417#endif
418 418
419#if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ 419#if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \
420 defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) || \ 420 || defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) \
421 defined(HAVE_TLV320) 421 || defined(HAVE_WM8721) || defined(HAVE_TLV320)
422 /* volume/balance/treble/bass interdependency main part */ 422 /* volume/balance/treble/bass interdependency main part */
423#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN) 423#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
424 424
@@ -450,7 +450,8 @@ static void set_prescaled_volume(void)
450 mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]); 450 mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
451#elif defined(HAVE_UDA1380) 451#elif defined(HAVE_UDA1380)
452 uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); 452 uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
453#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 453#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
454 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
454 wmcodec_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); 455 wmcodec_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
455#endif 456#endif
456 457
@@ -476,7 +477,8 @@ static void set_prescaled_volume(void)
476 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); 477 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
477#elif defined(HAVE_UDA1380) 478#elif defined(HAVE_UDA1380)
478 uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r)); 479 uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r));
479#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 480#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
481 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
480 wmcodec_set_master_vol(tenthdb2master(l), tenthdb2master(r)); 482 wmcodec_set_master_vol(tenthdb2master(l), tenthdb2master(r));
481#if defined(HAVE_WM8975) || defined(HAVE_WM8758) 483#if defined(HAVE_WM8975) || defined(HAVE_WM8758)
482 wmcodec_set_lineout_vol(tenthdb2master(0), tenthdb2master(0)); 484 wmcodec_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
@@ -589,9 +591,9 @@ void sound_set_volume(int value)
589#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 591#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
590 unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8; 592 unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8;
591 mas_codec_writereg(0x10, tmp); 593 mas_codec_writereg(0x10, tmp);
592#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ 594#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \
593 defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 || \ 595 || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
594 defined(HAVE_TLV320) 596 || defined(HAVE_WM8721) || defined(HAVE_TLV320)
595 current_volume = value * 10; /* tenth of dB */ 597 current_volume = value * 10; /* tenth of dB */
596 set_prescaled_volume(); 598 set_prescaled_volume();
597#elif CONFIG_CPU == PNX0101 599#elif CONFIG_CPU == PNX0101
@@ -607,9 +609,9 @@ void sound_set_balance(int value)
607#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 609#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
608 unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8; 610 unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8;
609 mas_codec_writereg(0x11, tmp); 611 mas_codec_writereg(0x11, tmp);
610#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 || \ 612#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 \
611 defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 || \ 613 || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
612 defined(HAVE_TLV320) 614 || defined(HAVE_WM8721) || defined(HAVE_TLV320)
613 current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */ 615 current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
614 set_prescaled_volume(); 616 set_prescaled_volume();
615#elif CONFIG_CPU == PNX0101 617#elif CONFIG_CPU == PNX0101
@@ -634,7 +636,8 @@ void sound_set_bass(int value)
634 uda1380_set_bass(value >> 1); 636 uda1380_set_bass(value >> 1);
635 current_bass = value * 10; 637 current_bass = value * 10;
636 set_prescaled_volume(); 638 set_prescaled_volume();
637#elif defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 639#elif defined HAVE_WM8975 || defined HAVE_WM8758 \
640 || defined HAVE_WM8731 || defined(HAVE_WM8721)
638 current_bass = value * 10; 641 current_bass = value * 10;
639 wmcodec_set_bass(value); 642 wmcodec_set_bass(value);
640 set_prescaled_volume(); 643 set_prescaled_volume();
@@ -659,7 +662,8 @@ void sound_set_treble(int value)
659 uda1380_set_treble(value >> 1); 662 uda1380_set_treble(value >> 1);
660 current_treble = value * 10; 663 current_treble = value * 10;
661 set_prescaled_volume(); 664 set_prescaled_volume();
662#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) 665#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
666 || defined(HAVE_WM8731) || defined(HAVE_WM8721)
663 wmcodec_set_treble(value); 667 wmcodec_set_treble(value);
664 current_treble = value * 10; 668 current_treble = value * 10;
665 set_prescaled_volume(); 669 set_prescaled_volume();