Index: apps/keymaps/keymap-clip.c =================================================================== --- apps/keymaps/keymap-clip.c (revision 19711) +++ apps/keymaps/keymap-clip.c (working copy) @@ -212,12 +212,19 @@ /** FM Radio Screen **/ static const struct button_mapping button_context_radio[] = { - { ACTION_FM_MENU, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_FM_PRESET, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, - { ACTION_FM_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_NONE }, - { ACTION_FM_MODE, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, - { ACTION_FM_EXIT, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE }, + /* Copied from keymap-c200.c 20081207. Feel free to suggest a better one.*/ + { ACTION_NONE, BUTTON_UP, BUTTON_NONE }, + { ACTION_FM_MENU, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_FM_PRESET, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_FM_STOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, +/* { ACTION_FM_MODE, BUTTON_REC, BUTTON_NONE }, */ + { ACTION_FM_EXIT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, { ACTION_FM_PLAY, BUTTON_UP|BUTTON_REL, BUTTON_UP }, + { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) }; /* button_context_radio */ Index: firmware/export/config-clip.h =================================================================== --- firmware/export/config-clip.h (revision 19711) +++ firmware/export/config-clip.h (working copy) @@ -20,13 +20,12 @@ #define REC_FREQ_DEFAULT REC_FREQ_22 /* Default is not 44.1kHz */ #define REC_SAMPR_DEFAULT SAMPR_22 +#endif /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) -#endif - /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -103,10 +102,8 @@ #define AB_REPEAT_ENABLE 1 /* FM Tuner */ -#if 0 /* disabled since there is no driver (yet) */ #define CONFIG_TUNER SI4700 /* in fact SI4702 but let's hope it's compatible */ //#define HAVE_TUNER_PWR_CTRL -#endif /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT Index: firmware/export/config-fuze.h =================================================================== --- firmware/export/config-fuze.h (revision 19711) +++ firmware/export/config-fuze.h (working copy) @@ -19,8 +19,8 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ +#endif #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) -#endif /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -99,7 +99,7 @@ #define AB_REPEAT_ENABLE 1 /* FM Tuner - suspected to be the SI4702 */ -//#define CONFIG_TUNER SI4700 +#define CONFIG_TUNER SI4700 /* #define HAVE_TUNER_PWR_CTRL */ /* Define this for LCD backlight available */ Index: firmware/export/config-e200v2.h =================================================================== --- firmware/export/config-e200v2.h (revision 19711) +++ firmware/export/config-e200v2.h (working copy) @@ -17,10 +17,10 @@ #define REC_FREQ_DEFAULT REC_FREQ_22 /* Default is not 44.1kHz */ #define REC_SAMPR_DEFAULT SAMPR_22 +#endif /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) -#endif /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -99,7 +99,7 @@ #define AB_REPEAT_ENABLE 1 /* FM Tuner - suspected to be the SI4702 */ -//#define CONFIG_TUNER SI4700 +#define CONFIG_TUNER SI4700 /* #define HAVE_TUNER_PWR_CTRL */ /* Define this for LCD backlight available */ Index: firmware/export/as3514.h =================================================================== --- firmware/export/as3514.h (revision 19711) +++ firmware/export/as3514.h (working copy) @@ -27,6 +27,7 @@ extern void audiohw_set_master_vol(int vol_l, int vol_r); extern void audiohw_set_lineout_vol(int vol_l, int vol_r); extern void audiohw_set_frequency(int fsel); +void audiohw_set_linein_bypass(int line); /* Register Descriptions */ #define AS3514_LINE_OUT_R 0x00 @@ -203,6 +204,8 @@ #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) Index: firmware/target/arm/as3525/system-as3525.c =================================================================== --- firmware/target/arm/as3525/system-as3525.c (revision 19711) +++ firmware/target/arm/as3525/system-as3525.c (working copy) @@ -26,6 +26,7 @@ #include "ascodec-target.h" #include "dma-target.h" #include "clock-target.h" +#include "fmradio_i2c.h" #define default_interrupt(name) \ extern __attribute__((weak,alias("UIRQ"))) void name (void) @@ -263,6 +264,10 @@ * We don't need the power button in the bootloader. */ ascodec_init(); ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) & (1<<2)); + +#ifdef CONFIG_TUNER + fmradio_i2c_init(); +#endif #endif /* !BOOTLOADER */ #ifdef HAVE_ADJUSTABLE_CPU_FREQ Index: firmware/target/arm/as3525/audio-as3525.c =================================================================== --- firmware/target/arm/as3525/audio-as3525.c (revision 19711) +++ firmware/target/arm/as3525/audio-as3525.c (working copy) @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright © 2008 Rafaël Carré + * Copyright (C) 2007 by Michael Sevakis * * 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_linein_bypass(0); + } + break; + + case AUDIO_SRC_FMRADIO: /* recording and playback */ + audio_channels = 2; + if (source == last_source) + break; + + audiohw_set_linein_bypass(2); + break; + } /* end switch */ + + last_source = source; +} /* audio_input_mux */ + Index: firmware/drivers/audio/as3514.c =================================================================== --- firmware/drivers/audio/as3514.c (revision 19711) +++ firmware/drivers/audio/as3514.c (working copy) @@ -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 */ @@ -60,7 +68,9 @@ SOURCE_DAC = 0, SOURCE_MIC1, SOURCE_LINE_IN1, - SOURCE_LINE_IN1_ANALOG + SOURCE_LINE_IN2, + SOURCE_LINE_IN1_ANALOG, + SOURCE_LINE_IN2_ANALOG }; static unsigned int source = SOURCE_DAC; @@ -222,11 +232,14 @@ if (source == SOURCE_LINE_IN1_ANALOG) { mix_reg_r = AS3514_LINE_IN1_R; mix_reg_l = AS3514_LINE_IN1_L; + } else if (source == SOURCE_LINE_IN2_ANALOG) { + mix_reg_r = AS3514_LINE_IN2_R; + mix_reg_l = AS3514_LINE_IN2_L; } else { mix_reg_r = AS3514_DAC_R; mix_reg_l = AS3514_DAC_L; } - + /* We combine the mixer channel volume range with the headphone volume range - keep first stage as loud as possible */ if (vol_r <= 0x16) { @@ -253,10 +266,8 @@ 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) @@ -307,23 +318,27 @@ 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 { - source = SOURCE_LINE_IN1; - + source = (LINE_INPUT == 1) ? SOURCE_LINE_IN1 : SOURCE_LINE_IN2; + + /* Sync mixer volumes before switching inputs */ audiohw_set_master_vol(as3514.vol_l, as3514.vol_r); - /* 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 */ @@ -339,10 +354,8 @@ /* 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); audiohw_set_master_vol(as3514.vol_l, as3514.vol_r); } @@ -397,25 +410,56 @@ } /** - * Enable line in 1 analog monitoring + * Enable line in analog monitoring * */ void audiohw_set_monitor(bool enable) { if (enable) { - source = SOURCE_LINE_IN1_ANALOG; + audiohw_set_linein_bypass(LINE_INPUT); + } + else { + audiohw_set_linein_bypass(0); + } +} - as3514_set(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); +#endif /* HAVE_RECORDING */ + +/** + * Enable line-in bypass (0 = disable, 1 = linein1, 2 = linein2) + * + */ +void audiohw_set_linein_bypass(int line) +{ + switch (line) { + case 1: + source = SOURCE_LINE_IN1_ANALOG; + as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on, + AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_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); - } - else { - as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on); + break; + + case 2: + source = SOURCE_LINE_IN2_ANALOG; + as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_LIN2_on, + AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on); + as3514_set(AS3514_LINE_IN2_R, LINE_IN2_R_LI2R_MUTE_off); + as3514_set(AS3514_LINE_IN2_L, LINE_IN2_L_LI2L_MUTE_off); + break; + + default: + /* 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); + break; } /* Sync mixer volume */ audiohw_set_master_vol(as3514.vol_l, as3514.vol_r); } -#endif /* HAVE_RECORDING */ + +