From ea7f1430960cc6ccc16f67fe43c95d2341033642 Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Thu, 5 Feb 2009 19:57:18 +0000 Subject: FS#9611 - Sansa Clip radio code. Commit final part which enables the LINE2 input that carries the analog radio signal on ams sansas. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19927 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/audio/as3514.c | 76 +++++++++++++++++++++---------- firmware/export/as3514.h | 2 + firmware/export/audiohw.h | 7 ++- firmware/target/arm/as3525/audio-as3525.c | 43 ++++++++++++++--- 4 files changed, 95 insertions(+), 33 deletions(-) diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index 23d1c52b56..dc6efb511a 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c @@ -31,6 +31,14 @@ #include "i2s.h" #include "ascodec.h" +/* AMS Sansas based on the AS3525 use the LINE2 input for the analog radio + signal instead of LINE1 */ +#if CONFIG_CPU == AS3525 +#define LINE_INPUT 2 +#else +#define LINE_INPUT 1 +#endif + const struct sound_settings_info audiohw_settings[] = { [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, /* HAVE_SW_TONE_CONTROLS */ @@ -227,9 +235,13 @@ void audiohw_set_master_vol(int vol_l, int vol_r) as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); -#ifdef HAVE_RECORDING - as3514_write_masked(AS3514_LINE_IN1_R, mix_r, AS3514_VOL_MASK); - as3514_write_masked(AS3514_LINE_IN1_L, mix_l, AS3514_VOL_MASK); +#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN) + as3514_write_masked((LINE_INPUT == 1) ? AS3514_LINE_IN1_R : + AS3514_LINE_IN2_R, + mix_r, AS3514_VOL_MASK); + as3514_write_masked((LINE_INPUT == 1) ? AS3514_LINE_IN1_L : + AS3514_LINE_IN2_L, + mix_l, AS3514_VOL_MASK); #endif as3514_write_masked(AS3514_HPH_OUT_R, hph_r, AS3514_VOL_MASK); as3514_write_masked(AS3514_HPH_OUT_L, hph_l, AS3514_VOL_MASK); @@ -237,10 +249,8 @@ void audiohw_set_master_vol(int vol_l, int vol_r) void audiohw_set_lineout_vol(int vol_l, int vol_r) { - as3514_write_masked(AS3514_LINE_OUT_R, vol_r, - AS3514_VOL_MASK); - as3514_write_masked(AS3514_LINE_OUT_L, vol_l, - AS3514_VOL_MASK); + as3514_write_masked(AS3514_LINE_OUT_R, vol_r, AS3514_VOL_MASK); + as3514_write_masked(AS3514_LINE_OUT_L, vol_l, AS3514_VOL_MASK); } void audiohw_mute(bool mute) @@ -286,19 +296,24 @@ void audiohw_enable_recording(bool source_mic) as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_ST_MIC, ADC_R_ADCMUX); - /* MIC1_on, LIN1_off */ - as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_MIC1_on, - AUDIOSET1_MIC1_on | AUDIOSET1_LIN1_on); + /* MIC1_on, others off */ + as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_MIC1_on, + AUDIOSET1_INPUT_MASK); + /* M1_AGC_off */ as3514_clear(AS3514_MIC1_R, MIC1_R_M1_AGC_off); } else { - /* ADCmux = Line_IN1 */ - as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_LINE_IN1, + /* ADCmux = Line_IN1 or Line_IN2 */ + as3514_write_masked(AS3514_ADC_R, + (LINE_INPUT == 1) ? ADC_R_ADCMUX_LINE_IN1 : + ADC_R_ADCMUX_LINE_IN2, ADC_R_ADCMUX); - /* MIC1_off, LIN1_on */ - as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on, - AUDIOSET1_MIC1_on | AUDIOSET1_LIN1_on); + /* LIN1_or LIN2 on, rest off */ + as3514_write_masked(AS3514_AUDIOSET1, + (LINE_INPUT == 1) ? AUDIOSET1_LIN1_on : + AUDIOSET1_LIN2_on, + AUDIOSET1_INPUT_MASK); } /* ADC_Mute_off */ @@ -312,10 +327,8 @@ void audiohw_disable_recording(void) /* ADC_Mute_on */ as3514_clear(AS3514_ADC_L, ADC_L_ADC_MUTE_off); - /* ADC_off, LIN1_off, MIC_off */ - as3514_clear(AS3514_AUDIOSET1, - AUDIOSET1_ADC_on | AUDIOSET1_LIN1_on | - AUDIOSET1_MIC1_on); + /* ADC_off, all input sources off */ + as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_ADC_on | AUDIOSET1_INPUT_MASK); } /** @@ -366,22 +379,35 @@ void audiohw_set_recvol(int left, int right, int type) as3514_write_masked(AS3514_ADC_R, right, AS3514_VOL_MASK); as3514_write_masked(AS3514_ADC_L, left, AS3514_VOL_MASK); } +#endif /* HAVE_RECORDING */ +#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN) /** - * Enable line in 1 analog monitoring + * Enable line in analog monitoring * */ void audiohw_set_monitor(bool enable) { if (enable) { - as3514_set(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); - as3514_set(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); - as3514_set(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); + /* select either LIN1 or LIN2 */ + as3514_write_masked(AS3514_AUDIOSET1, + (LINE_INPUT == 1) ? + AUDIOSET1_LIN1_on : AUDIOSET1_LIN2_on, + AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); + as3514_set((LINE_INPUT == 1) ? AS3514_LINE_IN1_R : AS3514_LINE_IN2_R, + LINE_IN1_R_LI1R_MUTE_off); + as3514_set((LINE_INPUT == 1) ? AS3514_LINE_IN1_L : AS3514_LINE_IN2_L, + LINE_IN1_L_LI1L_MUTE_off); } else { - as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); + /* turn off both LIN1 and LIN2 */ as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off); as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off); + as3514_clear(AS3514_LINE_IN2_R, LINE_IN2_R_LI2R_MUTE_off); + as3514_clear(AS3514_LINE_IN2_L, LINE_IN2_L_LI2L_MUTE_off); + as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); } } -#endif /* HAVE_RECORDING */ +#endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */ + + diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index aeabb16144..53851335c8 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h @@ -202,6 +202,8 @@ extern void audiohw_set_lineout_vol(int vol_l, int vol_r); #define AUDIOSET1_LIN1_on (0x1 << 2) #define AUDIOSET1_MIC2_on (0x1 << 1) #define AUDIOSET1_MIC1_on (0x1 << 0) +#define AUDIOSET1_INPUT_MASK AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \ + AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on /* AUDIOSET2 (15h) */ #define AUDIOSET2_BIAS_off (0x1 << 7) diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index 7dba54a8a2..b173feb77f 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h @@ -272,14 +272,17 @@ void audiohw_disable_recording(void); */ void audiohw_set_recvol(int left, int right, int type); +#endif /*HAVE_RECORDING*/ + +#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN) + /** * Enable or disable recording monitor. * @param enable ture or false. */ void audiohw_set_monitor(bool enable); -#endif /*HAVE_RECORDING*/ - +#endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */ #if CONFIG_CODEC != SWCODEC diff --git a/firmware/target/arm/as3525/audio-as3525.c b/firmware/target/arm/as3525/audio-as3525.c index 63aaf367e8..410fdfad79 100644 --- a/firmware/target/arm/as3525/audio-as3525.c +++ b/firmware/target/arm/as3525/audio-as3525.c @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright © 2008 Rafaël Carré + * Copyright (C) 2009 by Bertrik Sikken * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,20 +18,51 @@ * KIND, either express or implied. * ****************************************************************************/ +#include "config.h" #include "system.h" #include "cpu.h" #include "audio.h" +#include "audiohw.h" #include "sound.h" -/* TODO */ +int audio_channels = 2; +int audio_output_source = AUDIO_SRC_PLAYBACK; void audio_set_output_source(int source) { - (void)source; -} + if ((unsigned)source >= AUDIO_NUM_SOURCES) + source = AUDIO_SRC_PLAYBACK; + + audio_output_source = source; +} /* audio_set_output_source */ void audio_input_mux(int source, unsigned flags) { - (void)source; + static int last_source = AUDIO_SRC_PLAYBACK; + (void)flags; -} + + switch (source) + { + default: /* playback - no recording */ + source = AUDIO_SRC_PLAYBACK; + case AUDIO_SRC_PLAYBACK: + audio_channels = 2; + if (source != last_source) + { + audiohw_set_monitor(false); + } + break; + + case AUDIO_SRC_FMRADIO: /* recording and playback */ + audio_channels = 2; + if (source == last_source) + break; + + audiohw_set_monitor(true); + break; + } /* end switch */ + + last_source = source; +} /* audio_input_mux */ + -- cgit v1.2.3