2006-12-18 01:52:21 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Michael Sevakis
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-12-18 01:52:21 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "system.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "sound.h"
|
|
|
|
|
2008-07-16 11:02:14 +00:00
|
|
|
#if INPUT_SRC_CAPS != 0
|
2006-12-18 01:52:21 +00:00
|
|
|
void audio_set_output_source(int source)
|
|
|
|
{
|
|
|
|
if ((unsigned)source >= AUDIO_NUM_SOURCES)
|
|
|
|
source = AUDIO_SRC_PLAYBACK;
|
|
|
|
} /* audio_set_output_source */
|
|
|
|
|
2007-06-08 23:42:04 +00:00
|
|
|
void audio_input_mux(int source, unsigned flags)
|
2006-12-18 01:52:21 +00:00
|
|
|
{
|
2006-12-18 02:37:35 +00:00
|
|
|
(void)flags;
|
2006-12-18 01:52:21 +00:00
|
|
|
/* Prevent pops from unneeded switching */
|
|
|
|
static int last_source = AUDIO_SRC_PLAYBACK;
|
2008-12-12 11:20:58 +00:00
|
|
|
#ifdef HAVE_FMRADIO_REC
|
2007-11-11 16:00:33 +00:00
|
|
|
bool recording = flags & SRCF_RECORDING;
|
2006-12-18 01:52:21 +00:00
|
|
|
static bool last_recording = false;
|
2006-12-18 02:09:10 +00:00
|
|
|
#endif
|
2006-12-18 01:52:21 +00:00
|
|
|
|
2008-12-12 11:01:07 +00:00
|
|
|
#if defined(IPOD_COLOR) || defined (IPOD_4G)
|
|
|
|
/* The usual magic from IPL - I'm guessing this configures the headphone
|
|
|
|
socket to be input or output. */
|
2008-12-12 11:20:58 +00:00
|
|
|
if ((flags & SRCF_RECORDING) && source != AUDIO_SRC_PLAYBACK)
|
2008-12-12 11:01:07 +00:00
|
|
|
{
|
|
|
|
/* input */
|
|
|
|
GPIO_CLEAR_BITWISE(GPIOI_OUTPUT_VAL, 0x40);
|
|
|
|
GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL, 0x04);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* output */
|
|
|
|
GPIO_SET_BITWISE(GPIOI_OUTPUT_VAL, 0x40);
|
|
|
|
GPIO_SET_BITWISE(GPIOA_OUTPUT_VAL, 0x04);
|
|
|
|
}
|
|
|
|
#endif /* IPOD_COLOR || IPOD_4G */
|
|
|
|
|
2006-12-18 01:52:21 +00:00
|
|
|
switch (source)
|
|
|
|
{
|
|
|
|
default: /* playback - no recording */
|
|
|
|
source = AUDIO_SRC_PLAYBACK;
|
|
|
|
case AUDIO_SRC_PLAYBACK:
|
2007-05-20 22:03:11 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2006-12-18 01:52:21 +00:00
|
|
|
if (source != last_source)
|
|
|
|
{
|
|
|
|
audiohw_set_monitor(false);
|
2007-11-11 19:11:23 +00:00
|
|
|
audiohw_disable_recording();
|
2006-12-18 01:52:21 +00:00
|
|
|
}
|
2007-05-20 22:03:11 +00:00
|
|
|
#endif
|
2006-12-18 01:52:21 +00:00
|
|
|
break;
|
2007-05-20 20:26:36 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-12-18 01:52:21 +00:00
|
|
|
case AUDIO_SRC_MIC: /* recording only */
|
|
|
|
if (source != last_source)
|
|
|
|
{
|
|
|
|
audiohw_set_monitor(false);
|
2007-11-11 19:11:23 +00:00
|
|
|
audiohw_enable_recording(true); /* source mic */
|
2006-12-18 01:52:21 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-05-20 20:26:36 +00:00
|
|
|
#endif
|
2007-11-11 23:41:54 +00:00
|
|
|
#ifdef HAVE_LINE_REC
|
2006-12-18 01:52:21 +00:00
|
|
|
case AUDIO_SRC_LINEIN: /* recording only */
|
2007-11-11 16:00:33 +00:00
|
|
|
#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
|
|
|
|
/* Switch line in source to line-in */
|
|
|
|
GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
|
|
|
|
#endif
|
2006-12-18 01:52:21 +00:00
|
|
|
if (source != last_source)
|
|
|
|
{
|
|
|
|
audiohw_set_monitor(false);
|
2007-11-11 19:11:23 +00:00
|
|
|
audiohw_enable_recording(false); /* source line */
|
2006-12-18 01:52:21 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-12-18 02:37:35 +00:00
|
|
|
#endif
|
2007-05-20 20:26:36 +00:00
|
|
|
#ifdef HAVE_FMRADIO_REC
|
2006-12-18 01:52:21 +00:00
|
|
|
case AUDIO_SRC_FMRADIO: /* recording and playback */
|
2007-11-11 16:00:33 +00:00
|
|
|
#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
|
|
|
|
/* Switch line in source to tuner */
|
|
|
|
GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
|
2008-05-31 08:31:46 +00:00
|
|
|
/* Set line-in vol to +12dB, which is proper for H10's */
|
|
|
|
if (!recording)
|
|
|
|
audiohw_set_recvol(0x1f, 0x1f, AUDIO_GAIN_LINEIN);
|
|
|
|
#else /* Set line-in vol to 0dB*/
|
2006-12-18 01:52:21 +00:00
|
|
|
if (!recording)
|
2007-11-11 16:00:33 +00:00
|
|
|
audiohw_set_recvol(0x17, 0x17, AUDIO_GAIN_LINEIN);
|
2008-05-31 08:31:46 +00:00
|
|
|
#endif
|
2006-12-18 01:52:21 +00:00
|
|
|
if (source == last_source && recording == last_recording)
|
|
|
|
break;
|
|
|
|
|
|
|
|
last_recording = recording;
|
|
|
|
|
2007-11-11 19:11:23 +00:00
|
|
|
if (recording)
|
|
|
|
{
|
|
|
|
audiohw_set_monitor(false); /* disable bypass mode */
|
|
|
|
audiohw_enable_recording(false); /* select line-in source */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
audiohw_disable_recording();
|
|
|
|
audiohw_set_monitor(true); /* enable bypass mode */
|
|
|
|
}
|
2006-12-18 01:52:21 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
} /* end switch */
|
|
|
|
|
|
|
|
last_source = source;
|
2007-06-08 23:42:04 +00:00
|
|
|
} /* audio_input_mux */
|
2008-07-16 11:02:14 +00:00
|
|
|
#endif /* INPUT_SRC_CAPS != 0 */
|