forked from len0rd/rockbox
No more ear doctor visits after powering/unpowering the Gigabeat. Cleanup a little too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13312 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
441a8d8054
commit
d989f19eda
5 changed files with 45 additions and 88 deletions
|
@ -78,53 +78,45 @@ static int tone_tenthdb2hw(int value)
|
|||
|
||||
void audiohw_reset(void);
|
||||
|
||||
/* Silently enable / disable audio output */
|
||||
void audiohw_enable_output(bool enable)
|
||||
/* Reset and power up the WM8751 */
|
||||
void audiohw_preinit(void)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
/* reset the I2S controller into known state */
|
||||
i2s_reset();
|
||||
/*
|
||||
* 1. Switch on power supplies.
|
||||
* By default the WM8751 is in Standby Mode, the DAC is
|
||||
* digitally muted and the Audio Interface, Line outputs
|
||||
* and Headphone outputs are all OFF (DACMU = 1 Power
|
||||
* Management registers 1 and 2 are all zeros).
|
||||
*/
|
||||
wmcodec_write(RESET, RESET_RESET); /*Reset*/
|
||||
|
||||
/*
|
||||
* 1. Switch on power supplies.
|
||||
* By default the WM87551L is in Standby Mode, the DAC is
|
||||
* digitally muted and the Audio Interface, Line outputs
|
||||
* and Headphone outputs are all OFF (DACMU = 1 Power
|
||||
* Management registers 1 and 2 are all zeros).
|
||||
*/
|
||||
wmcodec_write(RESET, RESET_RESET); /*Reset*/
|
||||
/* 2. Enable Vmid and VREF. */
|
||||
wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_5K);
|
||||
|
||||
/* 2. Enable Vmid and VREF. */
|
||||
wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_500K);
|
||||
/* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
|
||||
/* IWL=00(16 bit) FORMAT=10(I2S format) */
|
||||
wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 |
|
||||
AINTFCE_FORMAT_I2S);
|
||||
}
|
||||
|
||||
/* From app notes: allow Vref to stabilize to reduce clicks */
|
||||
sleep(HZ/2);
|
||||
/* Enable DACs and audio output after a short delay */
|
||||
void audiohw_postinit(void)
|
||||
{
|
||||
/* From app notes: allow Vref to stabilize to reduce clicks */
|
||||
sleep(HZ);
|
||||
|
||||
/* 3. Enable DACs as required. */
|
||||
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR);
|
||||
|
||||
/* 4. Enable line and / or headphone output buffers as required. */
|
||||
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
||||
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 |
|
||||
PWRMGMT2_ROUT2);
|
||||
|
||||
/* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
|
||||
/* IWL=00(16 bit) FORMAT=10(I2S format) */
|
||||
wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 |
|
||||
AINTFCE_FORMAT_I2S);
|
||||
/* 3. Enable DACs as required. */
|
||||
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR);
|
||||
|
||||
/* Keep it quiet */
|
||||
wmcodec_write(LOUT1, LOUT1_BITS | OUTPUT_MUTED);
|
||||
wmcodec_write(ROUT1, ROUT1_BITS | OUTPUT_MUTED);
|
||||
wmcodec_write(LOUT2, LOUT2_BITS | OUTPUT_MUTED);
|
||||
wmcodec_write(ROUT2, ROUT2_BITS | OUTPUT_MUTED);
|
||||
/* 4. Enable line and / or headphone output buffers as required. */
|
||||
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
||||
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 |
|
||||
PWRMGMT2_ROUT2);
|
||||
|
||||
wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO | LEFTMIX1_LI2LO_DEFAULT);
|
||||
wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO | RIGHTMIX2_RI2RO_DEFAULT);
|
||||
}
|
||||
wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO | LEFTMIX1_LI2LO_DEFAULT);
|
||||
wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO | RIGHTMIX2_RI2RO_DEFAULT);
|
||||
|
||||
audiohw_mute(!enable);
|
||||
audiohw_mute(false);
|
||||
}
|
||||
|
||||
int audiohw_set_master_vol(int vol_l, int vol_r)
|
||||
|
|
|
@ -28,6 +28,7 @@ extern int tenthdb2mixer(int db);
|
|||
|
||||
extern void audiohw_reset(void);
|
||||
extern int audiohw_init(void);
|
||||
extern void audiohw_preinit(void);
|
||||
extern void audiohw_enable_output(bool enable);
|
||||
extern int audiohw_set_master_vol(int vol_l, int vol_r);
|
||||
extern int audiohw_set_lineout_vol(int vol_l, int vol_r);
|
||||
|
|
|
@ -40,17 +40,7 @@
|
|||
#if CONFIG_TUNER
|
||||
#include "fmradio.h"
|
||||
#endif
|
||||
#ifdef HAVE_UDA1380
|
||||
#include "uda1380.h"
|
||||
#elif defined(HAVE_TLV320)
|
||||
#include "tlv320.h"
|
||||
#elif defined(HAVE_WM8758)
|
||||
#include "wm8758.h"
|
||||
#elif defined(HAVE_WM8975)
|
||||
#include "wm8975.h"
|
||||
#elif defined(HAVE_WM8731)
|
||||
#include "wm8731l.h"
|
||||
#endif
|
||||
#include "sound.h"
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "font.h"
|
||||
#endif
|
||||
|
@ -1323,15 +1313,10 @@ void shutdown_hw(void)
|
|||
|
||||
#if CONFIG_CODEC != SWCODEC
|
||||
mp3_shutdown();
|
||||
#else
|
||||
audiohw_close();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UDA1380
|
||||
audiohw_close();
|
||||
#elif defined(HAVE_TLV320)
|
||||
audiohw_close();
|
||||
#elif defined(HAVE_WM8758) || defined(HAVE_WM8975) | defined(HAVE_WM8731)
|
||||
audiohw_close();
|
||||
#endif
|
||||
/* If HD is still active we try to wait for spindown, otherwise the
|
||||
shutdown_timeout in power_thread_sleep will force a power off */
|
||||
while(ata_disk_is_active())
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#define GIGABEAT_44100HZ (0x11 << 1)
|
||||
#define GIGABEAT_88200HZ (0x1f << 1)
|
||||
|
||||
static int pcm_freq = HW_SAMPR_DEFAULT; /* 44.1 is default */
|
||||
static int sr_ctrl = GIGABEAT_44100HZ;
|
||||
static int pcm_freq = 0; /* 44.1 is default */
|
||||
static int sr_ctrl = 0;
|
||||
#define FIFO_COUNT ((IISFCON >> 6) & 0x01F)
|
||||
|
||||
/* number of bytes in FIFO */
|
||||
|
@ -71,11 +71,10 @@ void pcm_init(void)
|
|||
pcm_paused = false;
|
||||
pcm_callback_for_more = NULL;
|
||||
|
||||
audiohw_init();
|
||||
audiohw_enable_output(true);
|
||||
|
||||
pcm_set_frequency(SAMPR_44);
|
||||
|
||||
audiohw_init();
|
||||
|
||||
/* init GPIO */
|
||||
GPCCON = (GPCCON & ~(3<<14)) | (1<<14);
|
||||
GPCDAT |= 1<<7;
|
||||
|
@ -92,6 +91,7 @@ void pcm_init(void)
|
|||
void pcm_postinit(void)
|
||||
{
|
||||
audiohw_postinit();
|
||||
pcm_apply_settings();
|
||||
}
|
||||
|
||||
void pcm_play_dma_start(const void *addr, size_t size)
|
||||
|
|
|
@ -23,33 +23,14 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "lcd.h"
|
||||
#include "cpu.h"
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "power.h"
|
||||
#include "debug.h"
|
||||
#include "system.h"
|
||||
#include "sprintf.h"
|
||||
#include "button.h"
|
||||
#include "string.h"
|
||||
#include "file.h"
|
||||
#include "buffer.h"
|
||||
#include "audio.h"
|
||||
#include "sound.h"
|
||||
#include "i2c.h"
|
||||
#include "i2c-meg-fx.h"
|
||||
/*
|
||||
* Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
|
||||
*/
|
||||
void i2s_reset(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the WM8975 for playback via headphone and line out.
|
||||
* Note, I'm using the WM8750 datasheet as its apparently close.
|
||||
*/
|
||||
int audiohw_init(void) {
|
||||
int audiohw_init(void)
|
||||
{
|
||||
/* reset I2C */
|
||||
i2c_init();
|
||||
|
||||
|
@ -58,11 +39,9 @@ int audiohw_init(void) {
|
|||
GPCCON |= (1 << 10);
|
||||
GPCDAT |= (1 << 5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
audiohw_preinit();
|
||||
|
||||
void audiohw_postinit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wmcodec_write(int reg, int data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue