summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-03-30 20:18:02 +0000
committerJens Arnold <amiconn@rockbox.org>2006-03-30 20:18:02 +0000
commit7e0ea2153c24e00e3fdb8888fe19fc8fccca77c6 (patch)
treeff64fd5da311635bf751acf7c2a92aedebd69031
parentd5c927d92ffa50e893b389a88843a5ccd4409e03 (diff)
downloadrockbox-7e0ea2153c24e00e3fdb8888fe19fc8fccca77c6.zip
rockbox-7e0ea2153c24e00e3fdb8888fe19fc8fccca77c6.tar.gz
rockbox-7e0ea2153c24e00e3fdb8888fe19fc8fccca77c6.tar.bz2
rockbox-7e0ea2153c24e00e3fdb8888fe19fc8fccca77c6.tar.xz
iPod mini 2G: Define correct audio codec, and fix WM8731 driver to work with PP5020. Audio is working now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9367 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/settings.c3
-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
7 files changed, 89 insertions, 31 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 8c8a3ba..776960e 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -213,7 +213,8 @@ static const struct bit_entry rtc_bits[] =
#elif defined HAVE_UDA1380
{5, S_O(bass), 0, "bass", NULL }, /* 0..+24 */
{3, S_O(treble), 0, "treble", NULL }, /* 0..+6 */
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
{4 | SIGNED, S_O(bass), 0, "bass", NULL }, /* -6..+9 */
{4 | SIGNED, S_O(treble), 0, "treble", NULL }, /* -6..+9 */
#endif
diff --git a/firmware/SOURCES b/firmware/SOURCES
index d145176..4b2e63d 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -183,7 +183,7 @@ drivers/uda1380.c
drivers/wm8975.c
#elif defined(HAVE_WM8758) && !defined(SIMULATOR)
drivers/wm8758.c
-#elif defined(HAVE_WM8731) && !defined(SIMULATOR)
+#elif (defined(HAVE_WM8731) || defined(HAVE_WM8721)) && !defined(SIMULATOR)
drivers/wm8731l.c
#elif defined(HAVE_TLV320) && !defined(SIMULATOR)
drivers/tlv320.c
diff --git a/firmware/drivers/wm8731l.c b/firmware/drivers/wm8731l.c
index 990ad0e..52d8d1e 100644
--- a/firmware/drivers/wm8731l.c
+++ b/firmware/drivers/wm8731l.c
@@ -89,6 +89,27 @@ static void codec_set_active(int active)
*/
static void i2s_reset(void)
{
+#if CONFIG_CPU == PP5020
+ /* I2S soft reset */
+ outl(inl(0x70002800) | 0x80000000, 0x70002800);
+ outl(inl(0x70002800) & ~0x80000000, 0x70002800);
+
+ /* BIT.FORMAT [11:10] = I2S (default) */
+ outl(inl(0x70002800) & ~0xc00, 0x70002800);
+ /* BIT.SIZE [9:8] = 16bit (default) */
+ outl(inl(0x70002800) & ~0x300, 0x70002800);
+
+ /* FIFO.FORMAT [6:4] = 32 bit LSB */
+ /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */
+ outl(inl(0x70002800) | 0x30, 0x70002800);
+
+ /* RX_ATN_LVL=1 == when 12 slots full */
+ /* TX_ATN_LVL=1 == when 12 slots empty */
+ outl(inl(0x7000280c) | 0x33, 0x7000280c);
+
+ /* Rx.CLR = 1, TX.CLR = 1 */
+ outl(inl(0x7000280c) | 0x1100, 0x7000280c);
+#elif CONFIG_CPU == PP5002
/* I2S device reset */
outl(inl(0xcf005030) | 0x80, 0xcf005030);
outl(inl(0xcf005030) & ~0x80, 0xcf005030);
@@ -102,6 +123,7 @@ static void i2s_reset(void)
/* reset DAC and ADC fifo */
outl(inl(0xc000251c) | 0x30000, 0xc000251c);
+#endif
}
/*
@@ -112,6 +134,27 @@ int wmcodec_init(void) {
/* reset I2C */
i2c_init();
+#if CONFIG_CPU == PP5020
+ /* normal outputs for CDI and I2S pin groups */
+ outl(inl(0x70000020) & ~0x300, 0x70000020);
+
+ /*mini2?*/
+ outl(inl(0x70000010) & ~0x3000000, 0x70000010);
+ /*mini2?*/
+
+ /* device reset */
+ outl(inl(0x60006004) | 0x800, 0x60006004);
+ outl(inl(0x60006004) & ~0x800, 0x60006004);
+
+ /* device enable */
+ outl(inl(0x6000600C) | 0x807, 0x6000600C);
+
+ /* enable external dev clock clocks */
+ outl(inl(0x6000600c) | 0x2, 0x6000600c);
+
+ /* external dev clock to 24MHz */
+ outl(inl(0x70000018) & ~0xc, 0x70000018);
+#else
/* device reset */
outl(inl(0xcf005030) | 0x80, 0xcf005030);
outl(inl(0xcf005030) & ~0x80, 0xcf005030);
@@ -135,6 +178,7 @@ int wmcodec_init(void) {
outl(inl(0xcf000008) | 0x8, 0xcf000008);
outl(inl(0xcf000018) | 0x8, 0xcf000018);
outl(inl(0xcf000028) & ~0x8, 0xcf000028);
+#endif
return 0;
}
@@ -142,7 +186,7 @@ int wmcodec_init(void) {
/* Silently enable / disable audio output */
void wmcodec_enable_output(bool enable)
{
- if (enable)
+ if (enable)
{
/* reset the I2S controller into known state */
i2s_reset();
@@ -151,9 +195,13 @@ void wmcodec_enable_output(bool enable)
codec_set_active(0x0);
+#ifdef HAVE_WM8721
/* DACSEL=1 */
- /* BYPASS=1 */
+ wm8731_write(0x4, 0x10);
+#elif defined HAVE_WM8731
+ /* DACSEL=1, BYPASS=1 */
wm8731_write(0x4, 0x18);
+#endif
/* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
wm8731_write(PWRMGMT, 0x67);
diff --git a/firmware/export/config-ipodmini.h b/firmware/export/config-ipodmini.h
index ea3f4e5..b4e909c 100644
--- a/firmware/export/config-ipodmini.h
+++ b/firmware/export/config-ipodmini.h
@@ -40,8 +40,8 @@
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x80000
-/* Define this if you have the WM8975 audio codec */
-#define HAVE_WM8975
+/* Define this if you have the WM8721 audio codec */
+#define HAVE_WM8721 /* actually WM8731 but no recording */
/* Define this for LCD backlight available */
#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */
diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h
index 60d812f..83192cc 100755
--- a/firmware/export/config-ipodmini2g.h
+++ b/firmware/export/config-ipodmini2g.h
@@ -6,7 +6,7 @@
#define IPOD_ARCH 1
/* For Rolo and boot loader */
-#define MODEL_NUMBER 11
+#define MODEL_NUMBER 11
/* define this if you have recording possibility */
/*#define HAVE_RECORDING 1*/
@@ -40,8 +40,8 @@
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x80000
-/* Define this if you have the WM8975 audio codec */
-#define HAVE_WM8975
+/* Define this if you have the WM8721 audio codec */
+#define HAVE_WM8721 /* actually WM8731 but no recording */
/* Define this for LCD backlight available */
#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */
diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c
index 9e28891..d6dc41c 100644
--- a/firmware/pcm_playback.c
+++ b/firmware/pcm_playback.c
@@ -31,7 +31,7 @@
#include "wm8758.h"
#elif defined(HAVE_TLV320)
#include "tlv320.h"
-#elif defined(HAVE_WM8731)
+#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
#include "wm8731l.h"
#endif
#include "system.h"
@@ -237,7 +237,8 @@ void pcm_init(void)
dma_stop();
}
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
/* We need to unify this code with the uda1380 code as much as possible, but
we will keep it separate during early development.
@@ -522,7 +523,8 @@ void pcm_mute(bool mute)
{
#ifdef HAVE_UDA1380
uda1380_mute(mute);
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
wmcodec_mute(mute);
#elif defined(HAVE_TLV320)
tlv320_mute(mute);
@@ -557,7 +559,8 @@ void pcm_play_pause(bool play)
EBU1CONFIG = EBU_DEFPARM;
#endif
DCR0 |= DMA_EEXT | DMA_START;
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
/* Enable the FIFO and fill it */
enable_fiq();
@@ -616,7 +619,8 @@ void pcm_play_pause(bool play)
#ifdef HAVE_SPDIF_OUT
EBU1CONFIG = IIS_RESET | EBU_DEFPARM;
#endif
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
#if CONFIG_CPU == PP5020
/* Disable the interrupt */
IISCONFIG &= ~0x2;
@@ -672,7 +676,8 @@ void pcm_calculate_peaks(int *left, int *right)
#ifdef CPU_COLDFIRE
size_t samples = (BCR0 & 0xffffff) / 4;
addr = (short *) (SAR0 & ~3);
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
size_t samples = p_size / 4;
addr = p;
#endif
diff --git a/firmware/sound.c b/firmware/sound.c
index 9a3e9d4..e682d58 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -30,7 +30,7 @@
#include "wm8975.h"
#elif defined(HAVE_WM8758)
#include "wm8758.h"
-#elif defined(HAVE_WM8731)
+#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
#include "wm8731l.h"
#elif defined(HAVE_TLV320)
#include "tlv320.h"
@@ -81,7 +81,7 @@ static const struct sound_settings_info sound_settings_table[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble},
-#elif defined(HAVE_WM8731)
+#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
[SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble},
@@ -380,7 +380,7 @@ static int tenthdb2mixer(int db)
return -db * 2 / 5;
}
-#elif defined(HAVE_WM8731)
+#elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -730
#define VOLUME_MAX 60
@@ -416,9 +416,9 @@ static int tenthdb2mixer(int db)
#endif
-#if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \
- defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) || \
- defined(HAVE_TLV320)
+#if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \
+ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) \
+ || defined(HAVE_WM8721) || defined(HAVE_TLV320)
/* volume/balance/treble/bass interdependency main part */
#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
@@ -450,7 +450,8 @@ static void set_prescaled_volume(void)
mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
#elif defined(HAVE_UDA1380)
uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
wmcodec_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
#endif
@@ -476,7 +477,8 @@ static void set_prescaled_volume(void)
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
#elif defined(HAVE_UDA1380)
uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r));
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
wmcodec_set_master_vol(tenthdb2master(l), tenthdb2master(r));
#if defined(HAVE_WM8975) || defined(HAVE_WM8758)
wmcodec_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
@@ -589,9 +591,9 @@ void sound_set_volume(int value)
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8;
mas_codec_writereg(0x10, tmp);
-#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \
- defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 || \
- defined(HAVE_TLV320)
+#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \
+ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
+ || defined(HAVE_WM8721) || defined(HAVE_TLV320)
current_volume = value * 10; /* tenth of dB */
set_prescaled_volume();
#elif CONFIG_CPU == PNX0101
@@ -607,9 +609,9 @@ void sound_set_balance(int value)
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8;
mas_codec_writereg(0x11, tmp);
-#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 || \
- defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 || \
- defined(HAVE_TLV320)
+#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 \
+ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
+ || defined(HAVE_WM8721) || defined(HAVE_TLV320)
current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
set_prescaled_volume();
#elif CONFIG_CPU == PNX0101
@@ -634,7 +636,8 @@ void sound_set_bass(int value)
uda1380_set_bass(value >> 1);
current_bass = value * 10;
set_prescaled_volume();
-#elif defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731
+#elif defined HAVE_WM8975 || defined HAVE_WM8758 \
+ || defined HAVE_WM8731 || defined(HAVE_WM8721)
current_bass = value * 10;
wmcodec_set_bass(value);
set_prescaled_volume();
@@ -659,7 +662,8 @@ void sound_set_treble(int value)
uda1380_set_treble(value >> 1);
current_treble = value * 10;
set_prescaled_volume();
-#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
+#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \
+ || defined(HAVE_WM8731) || defined(HAVE_WM8721)
wmcodec_set_treble(value);
current_treble = value * 10;
set_prescaled_volume();