diff options
| -rw-r--r-- | apps/playback.c | 14 | ||||
| -rw-r--r-- | apps/playback.h | 1 | ||||
| -rw-r--r-- | firmware/drivers/tlv320.c | 10 | ||||
| -rw-r--r-- | firmware/drivers/uda1380.c | 13 | ||||
| -rw-r--r-- | firmware/export/sound.h | 2 | ||||
| -rw-r--r-- | firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c | 4 | ||||
| -rw-r--r-- | firmware/target/arm/wmcodec-pp.c | 4 | ||||
| -rw-r--r-- | firmware/target/coldfire/pcm-coldfire.c | 22 |
8 files changed, 49 insertions, 21 deletions
diff --git a/apps/playback.c b/apps/playback.c index 2ea6e2f..c3d2811 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -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 */ diff --git a/apps/playback.h b/apps/playback.h index ccf8b58..82179f1 100644 --- a/apps/playback.h +++ b/apps/playback.h @@ -74,7 +74,6 @@ extern void audio_prev_dir(void); #define audio_next_dir() #define audio_prev_dir() #endif -void audio_preinit(void); #endif diff --git a/firmware/drivers/tlv320.c b/firmware/drivers/tlv320.c index a88eae5..c0f28d3 100644 --- a/firmware/drivers/tlv320.c +++ b/firmware/drivers/tlv320.c @@ -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); } /** diff --git a/firmware/drivers/uda1380.c b/firmware/drivers/uda1380.c index 0001914..6984427 100644 --- a/firmware/drivers/uda1380.c +++ b/firmware/drivers/uda1380.c @@ -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) { diff --git a/firmware/export/sound.h b/firmware/export/sound.h index 1923840..99741c2 100644 --- a/firmware/export/sound.h +++ b/firmware/export/sound.h @@ -32,6 +32,8 @@ #include "tlv320.h" #endif +extern void audiohw_postinit(void); + enum { SOUND_VOLUME = 0, SOUND_BASS, diff --git a/firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c index fd023e1..fe42b75 100644 --- a/firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c @@ -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); diff --git a/firmware/target/arm/wmcodec-pp.c b/firmware/target/arm/wmcodec-pp.c index e252cf0..505a31d 100644 --- a/firmware/target/arm/wmcodec-pp.c +++ b/firmware/target/arm/wmcodec-pp.c @@ -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); diff --git a/firmware/target/coldfire/pcm-coldfire.c b/firmware/target/coldfire/pcm-coldfire.c index ef84700..720c77e 100644 --- a/firmware/target/coldfire/pcm-coldfire.c +++ b/firmware/target/coldfire/pcm-coldfire.c @@ -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 */ |