Get rid of remaining audiohw_enable_output style codec setup and use pre/post split initialization. Move some SoC-specific code like i2s_reset out of the codec drivers. Helps to unify drivers and it was only ever used to enable. I cannot possibly test everything so report (I'll be on call ;) or fix problems if any crop up.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19228 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-11-26 14:25:45 +00:00
parent e73383ea32
commit 888451fb0f
16 changed files with 77 additions and 159 deletions

View file

@ -90,16 +90,7 @@ void audiohw_init(void)
void audiohw_postinit(void)
{
}
/* Silently enable / disable audio output */
void audiohw_enable_output(bool enable)
{
if (enable) {
audiohw_mute(0);
} else {
audiohw_mute(1);
}
}
void audiohw_set_master_vol(int vol_l, int vol_r)

View file

@ -193,17 +193,6 @@ static int audiohw_set_regs(void)
return 0;
}
/* Silently enable / disable audio output */
void audiohw_enable_output(bool enable)
{
if (enable) {
uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_DAC | PON_HP);
} else {
uda1380_write_reg(REG_MUTE, MUTE_MASTER);
uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] & ~PON_DAC);
}
}
static void reset(void)
{
#ifdef IRIVER_H300_SERIES
@ -278,8 +267,9 @@ void audiohw_postinit(void)
/* Sleep a while so the power can stabilize (especially a long
delay is needed for the line out connector). */
sleep(HZ);
/* Power on FSDAC and HP amp. */
audiohw_enable_output(true);
uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_DAC | PON_HP);
/* UDA1380: Unmute the master channel
(DAC should be at zero point now). */

View file

@ -33,7 +33,6 @@
#include "wmcodec.h"
#include "audiohw.h"
#include "i2s.h"
#define IPOD_PCM_LEVEL 0x65 /* -6dB */
@ -91,13 +90,8 @@ static void codec_set_active(int active)
/* Silently enable / disable audio output */
void audiohw_enable_output(bool enable)
void audiohw_preinit(void)
{
if (enable)
{
/* reset the I2S controller into known state */
i2s_reset();
wmcodec_write(RESET, 0x0); /*Reset*/
codec_set_active(0x0);
@ -123,11 +117,11 @@ void audiohw_enable_output(bool enable)
/* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */
wmcodec_write(DAPCTRL, 0x0);
audiohw_mute(0);
} else {
audiohw_mute(1);
}
void audiohw_postinit(void)
{
audiohw_mute(0);
}
void audiohw_set_master_vol(int vol_l, int vol_r)

View file

@ -33,7 +33,6 @@
#include "wmcodec.h"
#include "audiohw.h"
#include "i2s.h"
#include "sound.h"
const struct sound_settings_info audiohw_settings[] = {
@ -150,8 +149,6 @@ static void codec_set_active(int active)
void audiohw_preinit(void)
{
i2s_reset();
/* POWER UP SEQUENCE */
/* 1) Switch on power supplies. By default the WM8731 is in Standby Mode,
* the DAC is digitally muted and the Audio Interface and Outputs are

View file

@ -27,7 +27,6 @@
****************************************************************************/
#include "kernel.h"
#include "wmcodec.h"
#include "i2s.h"
#include "audio.h"
#include "audiohw.h"
#include "system.h"

View file

@ -31,7 +31,6 @@
#include "wmcodec.h"
#include "audiohw.h"
#include "i2s.h"
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25},
@ -95,8 +94,6 @@ void audiohw_mute(bool mute)
void audiohw_preinit(void)
{
i2s_reset();
wmcodec_write(RESET, RESET_RESET);
wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN

View file

@ -33,7 +33,6 @@
#include "wmcodec.h"
#include "audiohw.h"
#include "i2s.h"
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25},
@ -129,8 +128,6 @@ void audiohw_mute(bool mute)
void audiohw_preinit(void)
{
i2s_reset();
/* POWER UP SEQUENCE */
wmcodec_write(RESET, RESET_RESET);

View file

@ -23,7 +23,6 @@
#include "wmcodec.h"
#include "audiohw.h"
#include "i2s.h"
/* Register addresses as per datasheet Rev.4.4 */
#define RESET 0x00
@ -127,13 +126,8 @@ int tenthdb2master(int db)
}
/* Silently enable / disable audio output */
void audiohw_enable_output(bool enable)
void audiohw_preinit(void)
{
if (enable)
{
/* TODO: reset the I2S controller into known state */
//i2s_reset();
wmcodec_write(RESET, 0x1ff); /* Reset */
wmcodec_write(BIASCTL, 0x100); /* BIASCUT = 1 */
@ -169,16 +163,14 @@ void audiohw_enable_output(bool enable)
wmcodec_write(RDACVOL, 0x1ff);
wmcodec_write(OUT4ADC, 0x0); /* POBCTRL = 0 */
}
void audiohw_postinit(void)
{
sleep(HZ/2);
audiohw_mute(0);
}
else
{
audiohw_mute(1);
}
}
void audiohw_set_headphone_vol(int vol_l, int vol_r)
{
@ -256,9 +248,6 @@ void audiohw_enable_recording(bool source_mic)
{
(void)source_mic; /* We only have a line-in (I think) */
/* TODO: reset the I2S controller into known state */
//i2s_reset();
wmcodec_write(RESET, 0x1ff); /*Reset*/
wmcodec_write(PWRMGMT1, 0x2b);

View file

@ -150,12 +150,13 @@ extern const struct sound_settings_info audiohw_settings[];
*/
/**
* Initialize audio codec to a well defined state.
* Initialize audio codec to a well defined state. Includes SoC-specific
* setup.
*/
void audiohw_init(void);
/**
* Do initial audio codec setup.
* Do initial audio codec setup. Usually called from audiohw_init.
*/
void audiohw_preinit(void);
@ -207,12 +208,6 @@ void audiohw_set_balance(int val);
*/
void audiohw_mute(bool mute);
/**
* Silently en/disable audio output.
* @param enable true or false.
*/
void audiohw_enable_output(bool enable);
#ifdef AUDIOHW_HAVE_TREBLE
/**
* Set new treble value.

View file

@ -373,14 +373,6 @@ void pcm_play_dma_init(void)
/* Initialize default register values. */
audiohw_init();
#if !defined(HAVE_WM8731) && !defined(HAVE_WM8751) && !defined(HAVE_WM8975) \
&& !defined(HAVE_WM8758) && !defined(HAVE_AS3514)
/* Power on */
audiohw_enable_output(true);
/* Unmute the master channel (DAC should be at zero point now). */
audiohw_mute(false);
#endif
dma_play_data.size = 0;
#if NUM_CORES > 1
dma_play_data.core = 0; /* no core in control */

View file

@ -109,18 +109,17 @@ void pcm_play_dma_init(void)
/* Initialize default register values. */
audiohw_init();
/* Power on */
audiohw_enable_output(true);
/* Unmute the master channel (DAC should be at zero point now). */
audiohw_mute(false);
dma_play_data.size = 0;
#if NUM_CORES > 1
dma_play_data.core = 0; /* no core in control */
#endif
}
void pcm_postinit(void)
{
audiohw_postinit();
}
void pcm_apply_settings(void)
{
pcm_curr_sampr = pcm_freq;

View file

@ -26,11 +26,6 @@
int audio_channels = 2;
int audio_output_source = AUDIO_SRC_PLAYBACK;
void audiohw_enable_output(bool on)
{
(void) on;
}
void audio_set_output_source(int source)
{
int oldmode = set_fiq_status(FIQ_DISABLED);

View file

@ -26,11 +26,6 @@
int audio_channels = 2;
int audio_output_source = AUDIO_SRC_PLAYBACK;
void audiohw_enable_output(bool on)
{
(void)on;
}
void audio_set_output_source(int source)
{
(void)source;

View file

@ -26,11 +26,6 @@
int audio_channels = 2;
int audio_output_source = AUDIO_SRC_PLAYBACK;
void audiohw_enable_output(bool on)
{
(void)on;
}
void audio_set_output_source(int source)
{
(void)source;

View file

@ -29,6 +29,7 @@
#include "system.h"
#include "audiohw.h"
#include "i2c-pp.h"
#include "i2s.h"
#include "wmcodec.h"
#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(MROBE_100)
@ -43,7 +44,8 @@
/*
* Initialise the PP I2C and I2S.
*/
void audiohw_init(void) {
void audiohw_init(void)
{
#ifdef CPU_PP502x
/* normal outputs for CDI and I2S pin groups */
DEV_INIT2 &= ~0x300;
@ -96,20 +98,12 @@ void audiohw_init(void) {
#endif /* IPOD_1G2G/3G */
#endif
#if defined(HAVE_WM8731) || defined(HAVE_WM8751) || defined(HAVE_WM8975) \
|| defined(HAVE_WM8758)
/* reset the I2S controller into known state */
i2s_reset();
audiohw_preinit();
#endif
}
#if !defined(HAVE_WM8731) && !defined(HAVE_WM8751) && !defined(HAVE_WM8975) \
&& !defined(HAVE_WM8758)
void audiohw_postinit(void)
{
}
#endif
void wmcodec_write(int reg, int data)
{
pp_i2c_send(I2C_AUDIO_ADDRESS, (reg<<1) | ((data&0x100)>>8),data&0xff);

View file

@ -50,12 +50,11 @@ void pcm_play_dma_init(void)
/* Initialize default register values. */
audiohw_init();
}
/* Power on */
audiohw_enable_output(true);
/* Unmute the master channel (DAC should be at zero point now). */
audiohw_mute(false);
void pcm_postinit(void)
{
audiohw_postinit();
}
void pcm_apply_settings(void)