Reenable aynchronous audio init stage. Really just single stage with aynchronous enabling of outputs. Keeps audio_init last so prior init steps can use the audiobuffer in any desired way. Audio will be fully initialized by the time the UI is entered. Playback of voice or audio will be delayed properly until audio hardware is ready.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12714 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a1a4034b82
commit
5d63776a24
8 changed files with 49 additions and 21 deletions
|
@ -3443,6 +3443,11 @@ static bool ata_fillbuffer_callback(void)
|
|||
static void audio_thread(void)
|
||||
{
|
||||
struct event ev;
|
||||
|
||||
audiohw_postinit();
|
||||
|
||||
/* Unlock mutex that init stage locks before creating this thread */
|
||||
mutex_unlock(&mutex_codecthread);
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -3604,6 +3609,10 @@ void audio_init(void)
|
|||
starts running until ready if something yields such as talk_init. */
|
||||
#ifdef PLAYBACK_VOICE
|
||||
mutex_init(&mutex_codecthread);
|
||||
/* Take ownership of lock to prevent playback of anything before audio
|
||||
hardware is initialized - audio thread unlocks it after final init
|
||||
stage */
|
||||
mutex_lock(&mutex_codecthread);
|
||||
#endif
|
||||
queue_init(&audio_queue, true);
|
||||
queue_enable_queue_send(&audio_queue, &audio_queue_sender_list);
|
||||
|
@ -3656,6 +3665,7 @@ void audio_init(void)
|
|||
|
||||
/* initialize the buffer */
|
||||
filebuf = audiobuf; /* must be non-NULL for audio_set_crossfade */
|
||||
|
||||
/* audio_reset_buffer must to know the size of voice buffer so init
|
||||
voice first */
|
||||
talk_init();
|
||||
|
@ -3670,9 +3680,9 @@ void audio_init(void)
|
|||
IF_COP(, CPU, false));
|
||||
|
||||
audio_set_crossfade(global_settings.crossfade);
|
||||
|
||||
|
||||
audio_is_initialized = true;
|
||||
|
||||
|
||||
sound_settings_apply();
|
||||
audio_set_buffer_margin(global_settings.buffer_margin);
|
||||
} /* audio_init */
|
||||
|
|
|
@ -74,7 +74,6 @@ extern void audio_prev_dir(void);
|
|||
#define audio_next_dir()
|
||||
#define audio_prev_dir()
|
||||
#endif
|
||||
void audio_preinit(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -99,8 +99,18 @@ void audiohw_init(void)
|
|||
tlv320_write_reg(REG_DAIF, DAIF_IWL_16 | DAIF_FOR_I2S);
|
||||
tlv320_write_reg(REG_DIA, DIA_ACT);
|
||||
audiohw_set_frequency(-1); /* default */
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch outputs ON
|
||||
*/
|
||||
void audiohw_postinit(void)
|
||||
{
|
||||
/* All ON except ADC, MIC and LINE */
|
||||
sleep(HZ);
|
||||
tlv320_write_reg(REG_PC, PC_ADC | PC_MIC | PC_LINE);
|
||||
sleep(HZ/4);
|
||||
audiohw_mute(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -270,6 +270,19 @@ int audiohw_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
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: Unmute the master channel
|
||||
(DAC should be at zero point now). */
|
||||
audiohw_mute(false);
|
||||
}
|
||||
|
||||
/* Nice shutdown of UDA1380 codec */
|
||||
void audiohw_close(void)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "tlv320.h"
|
||||
#endif
|
||||
|
||||
extern void audiohw_postinit(void);
|
||||
|
||||
enum {
|
||||
SOUND_VOLUME = 0,
|
||||
SOUND_BASS,
|
||||
|
|
|
@ -61,6 +61,10 @@ int audiohw_init(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void audiohw_postinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void wmcodec_write(int reg, int data)
|
||||
{
|
||||
i2c_send(0x34, (reg<<1) | ((data&0x100)>>8), data&0xff);
|
||||
|
|
|
@ -92,6 +92,10 @@ int audiohw_init(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void audiohw_postinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void wmcodec_write(int reg, int data)
|
||||
{
|
||||
pp_i2c_send(I2C_AUDIO_ADDRESS, (reg<<1) | ((data&0x100)>>8),data&0xff);
|
||||
|
|
|
@ -255,6 +255,10 @@ void pcm_init(void)
|
|||
pcm_play_dma_stop();
|
||||
/* Call pcm_close_recording to put in closed state */
|
||||
pcm_close_recording();
|
||||
|
||||
/* Initialize default register values. */
|
||||
audiohw_init();
|
||||
|
||||
audio_set_output_source(AUDIO_SRC_PLAYBACK);
|
||||
audio_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
||||
pcm_set_frequency(HW_FREQ_DEFAULT);
|
||||
|
@ -264,24 +268,6 @@ void pcm_init(void)
|
|||
#if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
|
||||
spdif_init();
|
||||
#endif
|
||||
|
||||
/* Initialize default register values. */
|
||||
audiohw_init();
|
||||
|
||||
#if defined(HAVE_UDA1380)
|
||||
/* 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);
|
||||
#elif defined(HAVE_TLV320)
|
||||
sleep(HZ/4);
|
||||
#endif
|
||||
|
||||
/* UDA1380: Unmute the master channel
|
||||
(DAC should be at zero point now). */
|
||||
audiohw_mute(false);
|
||||
|
||||
/* Enable interrupt at level 6, priority 0 */
|
||||
ICR6 = (6 << 2);
|
||||
and_l(~(1 << 14), &IMR); /* bit 14 is DMA0 */
|
||||
|
|
Loading…
Reference in a new issue