1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jens Arnold 2006-03-30 20:18:02 +00:00
parent d5c927d92f
commit 7e0ea2153c
7 changed files with 89 additions and 31 deletions

View file

@ -213,7 +213,8 @@ static const struct bit_entry rtc_bits[] =
#elif defined HAVE_UDA1380 #elif defined HAVE_UDA1380
{5, S_O(bass), 0, "bass", NULL }, /* 0..+24 */ {5, S_O(bass), 0, "bass", NULL }, /* 0..+24 */
{3, S_O(treble), 0, "treble", NULL }, /* 0..+6 */ {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(bass), 0, "bass", NULL }, /* -6..+9 */
{4 | SIGNED, S_O(treble), 0, "treble", NULL }, /* -6..+9 */ {4 | SIGNED, S_O(treble), 0, "treble", NULL }, /* -6..+9 */
#endif #endif

View file

@ -183,7 +183,7 @@ drivers/uda1380.c
drivers/wm8975.c drivers/wm8975.c
#elif defined(HAVE_WM8758) && !defined(SIMULATOR) #elif defined(HAVE_WM8758) && !defined(SIMULATOR)
drivers/wm8758.c drivers/wm8758.c
#elif defined(HAVE_WM8731) && !defined(SIMULATOR) #elif (defined(HAVE_WM8731) || defined(HAVE_WM8721)) && !defined(SIMULATOR)
drivers/wm8731l.c drivers/wm8731l.c
#elif defined(HAVE_TLV320) && !defined(SIMULATOR) #elif defined(HAVE_TLV320) && !defined(SIMULATOR)
drivers/tlv320.c drivers/tlv320.c

View file

@ -89,6 +89,27 @@ static void codec_set_active(int active)
*/ */
static void i2s_reset(void) 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 */ /* I2S device reset */
outl(inl(0xcf005030) | 0x80, 0xcf005030); outl(inl(0xcf005030) | 0x80, 0xcf005030);
outl(inl(0xcf005030) & ~0x80, 0xcf005030); outl(inl(0xcf005030) & ~0x80, 0xcf005030);
@ -102,6 +123,7 @@ static void i2s_reset(void)
/* reset DAC and ADC fifo */ /* reset DAC and ADC fifo */
outl(inl(0xc000251c) | 0x30000, 0xc000251c); outl(inl(0xc000251c) | 0x30000, 0xc000251c);
#endif
} }
/* /*
@ -112,6 +134,27 @@ int wmcodec_init(void) {
/* reset I2C */ /* reset I2C */
i2c_init(); 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 */ /* device reset */
outl(inl(0xcf005030) | 0x80, 0xcf005030); outl(inl(0xcf005030) | 0x80, 0xcf005030);
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(0xcf000008) | 0x8, 0xcf000008);
outl(inl(0xcf000018) | 0x8, 0xcf000018); outl(inl(0xcf000018) | 0x8, 0xcf000018);
outl(inl(0xcf000028) & ~0x8, 0xcf000028); outl(inl(0xcf000028) & ~0x8, 0xcf000028);
#endif
return 0; return 0;
} }
@ -151,9 +195,13 @@ void wmcodec_enable_output(bool enable)
codec_set_active(0x0); codec_set_active(0x0);
#ifdef HAVE_WM8721
/* DACSEL=1 */ /* DACSEL=1 */
/* BYPASS=1 */ wm8731_write(0x4, 0x10);
#elif defined HAVE_WM8731
/* DACSEL=1, BYPASS=1 */
wm8731_write(0x4, 0x18); wm8731_write(0x4, 0x18);
#endif
/* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */ /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
wm8731_write(PWRMGMT, 0x67); wm8731_write(PWRMGMT, 0x67);

View file

@ -40,8 +40,8 @@
/* The number of bytes reserved for loadable plugins */ /* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x80000 #define PLUGIN_BUFFER_SIZE 0x80000
/* Define this if you have the WM8975 audio codec */ /* Define this if you have the WM8721 audio codec */
#define HAVE_WM8975 #define HAVE_WM8721 /* actually WM8731 but no recording */
/* Define this for LCD backlight available */ /* Define this for LCD backlight available */
#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */ #define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */

View file

@ -40,8 +40,8 @@
/* The number of bytes reserved for loadable plugins */ /* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x80000 #define PLUGIN_BUFFER_SIZE 0x80000
/* Define this if you have the WM8975 audio codec */ /* Define this if you have the WM8721 audio codec */
#define HAVE_WM8975 #define HAVE_WM8721 /* actually WM8731 but no recording */
/* Define this for LCD backlight available */ /* Define this for LCD backlight available */
#define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */ #define CONFIG_BACKLIGHT BL_IPODMINI /* port controlled */

View file

@ -31,7 +31,7 @@
#include "wm8758.h" #include "wm8758.h"
#elif defined(HAVE_TLV320) #elif defined(HAVE_TLV320)
#include "tlv320.h" #include "tlv320.h"
#elif defined(HAVE_WM8731) #elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
#include "wm8731l.h" #include "wm8731l.h"
#endif #endif
#include "system.h" #include "system.h"
@ -237,7 +237,8 @@ void pcm_init(void)
dma_stop(); 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 need to unify this code with the uda1380 code as much as possible, but
we will keep it separate during early development. we will keep it separate during early development.
@ -522,7 +523,8 @@ void pcm_mute(bool mute)
{ {
#ifdef HAVE_UDA1380 #ifdef HAVE_UDA1380
uda1380_mute(mute); 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); wmcodec_mute(mute);
#elif defined(HAVE_TLV320) #elif defined(HAVE_TLV320)
tlv320_mute(mute); tlv320_mute(mute);
@ -557,7 +559,8 @@ void pcm_play_pause(bool play)
EBU1CONFIG = EBU_DEFPARM; EBU1CONFIG = EBU_DEFPARM;
#endif #endif
DCR0 |= DMA_EEXT | DMA_START; 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 the FIFO and fill it */
enable_fiq(); enable_fiq();
@ -616,7 +619,8 @@ void pcm_play_pause(bool play)
#ifdef HAVE_SPDIF_OUT #ifdef HAVE_SPDIF_OUT
EBU1CONFIG = IIS_RESET | EBU_DEFPARM; EBU1CONFIG = IIS_RESET | EBU_DEFPARM;
#endif #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 #if CONFIG_CPU == PP5020
/* Disable the interrupt */ /* Disable the interrupt */
IISCONFIG &= ~0x2; IISCONFIG &= ~0x2;
@ -672,7 +676,8 @@ void pcm_calculate_peaks(int *left, int *right)
#ifdef CPU_COLDFIRE #ifdef CPU_COLDFIRE
size_t samples = (BCR0 & 0xffffff) / 4; size_t samples = (BCR0 & 0xffffff) / 4;
addr = (short *) (SAR0 & ~3); 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; size_t samples = p_size / 4;
addr = p; addr = p;
#endif #endif

View file

@ -30,7 +30,7 @@
#include "wm8975.h" #include "wm8975.h"
#elif defined(HAVE_WM8758) #elif defined(HAVE_WM8758)
#include "wm8758.h" #include "wm8758.h"
#elif defined(HAVE_WM8731) #elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
#include "wm8731l.h" #include "wm8731l.h"
#elif defined(HAVE_TLV320) #elif defined(HAVE_TLV320)
#include "tlv320.h" #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_VOLUME] = {"dB", 0, 1, -58, 6, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, [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_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble},
@ -380,7 +380,7 @@ static int tenthdb2mixer(int db)
return -db * 2 / 5; return -db * 2 / 5;
} }
#elif defined(HAVE_WM8731) #elif defined(HAVE_WM8731) || defined(HAVE_WM8721)
/* volume/balance/treble/bass interdependency */ /* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -730 #define VOLUME_MIN -730
#define VOLUME_MAX 60 #define VOLUME_MAX 60
@ -416,9 +416,9 @@ static int tenthdb2mixer(int db)
#endif #endif
#if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ #if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \
defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) || \ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) \
defined(HAVE_TLV320) || defined(HAVE_WM8721) || defined(HAVE_TLV320)
/* volume/balance/treble/bass interdependency main part */ /* volume/balance/treble/bass interdependency main part */
#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN) #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]); mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
#elif defined(HAVE_UDA1380) #elif defined(HAVE_UDA1380)
uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); 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)); wmcodec_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
#endif #endif
@ -476,7 +477,8 @@ static void set_prescaled_volume(void)
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
#elif defined(HAVE_UDA1380) #elif defined(HAVE_UDA1380)
uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r)); 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)); wmcodec_set_master_vol(tenthdb2master(l), tenthdb2master(r));
#if defined(HAVE_WM8975) || defined(HAVE_WM8758) #if defined(HAVE_WM8975) || defined(HAVE_WM8758)
wmcodec_set_lineout_vol(tenthdb2master(0), tenthdb2master(0)); 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) #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8; unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8;
mas_codec_writereg(0x10, tmp); mas_codec_writereg(0x10, tmp);
#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ #elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \
defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 || \ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
defined(HAVE_TLV320) || defined(HAVE_WM8721) || defined(HAVE_TLV320)
current_volume = value * 10; /* tenth of dB */ current_volume = value * 10; /* tenth of dB */
set_prescaled_volume(); set_prescaled_volume();
#elif CONFIG_CPU == PNX0101 #elif CONFIG_CPU == PNX0101
@ -607,9 +609,9 @@ void sound_set_balance(int value)
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8; unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8;
mas_codec_writereg(0x11, tmp); mas_codec_writereg(0x11, tmp);
#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 || \ #elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 \
defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 || \ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
defined(HAVE_TLV320) || defined(HAVE_WM8721) || defined(HAVE_TLV320)
current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */ current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
set_prescaled_volume(); set_prescaled_volume();
#elif CONFIG_CPU == PNX0101 #elif CONFIG_CPU == PNX0101
@ -634,7 +636,8 @@ void sound_set_bass(int value)
uda1380_set_bass(value >> 1); uda1380_set_bass(value >> 1);
current_bass = value * 10; current_bass = value * 10;
set_prescaled_volume(); 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; current_bass = value * 10;
wmcodec_set_bass(value); wmcodec_set_bass(value);
set_prescaled_volume(); set_prescaled_volume();
@ -659,7 +662,8 @@ void sound_set_treble(int value)
uda1380_set_treble(value >> 1); uda1380_set_treble(value >> 1);
current_treble = value * 10; current_treble = value * 10;
set_prescaled_volume(); 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); wmcodec_set_treble(value);
current_treble = value * 10; current_treble = value * 10;
set_prescaled_volume(); set_prescaled_volume();