Straighten out some audio path APIs and misc. audio stuff. Having recording is not a prerequisite to having input/output source selection which is probably most useful when adding a audio input features like FM to a new port without forcing recording to be implemented first.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13599 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a85793fc54
commit
2d48d0ffa6
22 changed files with 237 additions and 154 deletions
|
@ -86,6 +86,9 @@ recorder/radio.c
|
||||||
recorder/recording.c
|
recorder/recording.c
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
#if INPUT_SRC_CAPS != 0
|
||||||
|
audio_path.c
|
||||||
|
#endif /* INPUT_SRC_CAPS != 0 */
|
||||||
pcmbuf.c
|
pcmbuf.c
|
||||||
playback.c
|
playback.c
|
||||||
codecs.c
|
codecs.c
|
||||||
|
|
145
apps/audio_path.c
Normal file
145
apps/audio_path.c
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Audio signal path management APIs
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Michael Sevakis
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* 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 "general.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
|
||||||
|
#ifdef HAVE_SPDIF_POWER
|
||||||
|
#include "power.h"
|
||||||
|
#endif
|
||||||
|
#include "spdif.h"
|
||||||
|
#endif
|
||||||
|
#if CONFIG_TUNER
|
||||||
|
#include "radio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some audio sources may require a boosted CPU */
|
||||||
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
|
#ifdef HAVE_SPDIF_REC
|
||||||
|
#define AUDIO_CPU_BOOST
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SIMULATOR
|
||||||
|
|
||||||
|
#ifdef AUDIO_CPU_BOOST
|
||||||
|
static void audio_cpu_boost(bool state)
|
||||||
|
{
|
||||||
|
static bool cpu_boosted = false;
|
||||||
|
|
||||||
|
if (state != cpu_boosted)
|
||||||
|
{
|
||||||
|
cpu_boost(state);
|
||||||
|
cpu_boosted = state;
|
||||||
|
}
|
||||||
|
} /* audio_cpu_boost */
|
||||||
|
#endif /* AUDIO_CPU_BOOST */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects an audio source for recording or playback
|
||||||
|
* powers/unpowers related devices and sets up monitoring.
|
||||||
|
*/
|
||||||
|
void audio_set_input_source(int source, unsigned flags)
|
||||||
|
{
|
||||||
|
/** Do power up/down of associated device(s) **/
|
||||||
|
|
||||||
|
/** SPDIF **/
|
||||||
|
#ifdef AUDIO_CPU_BOOST
|
||||||
|
/* Always boost for SPDIF */
|
||||||
|
audio_cpu_boost(source == AUDIO_SRC_SPDIF);
|
||||||
|
#endif /* AUDIO_CPU_BOOST */
|
||||||
|
|
||||||
|
#ifdef HAVE_SPDIF_POWER
|
||||||
|
/* Check if S/PDIF output power should be switched off or on. NOTE: assumes
|
||||||
|
both optical in and out is controlled by the same power source, which is
|
||||||
|
the case on H1x0. */
|
||||||
|
spdif_power_enable((source == AUDIO_SRC_SPDIF) ||
|
||||||
|
global_settings.spdif_enable);
|
||||||
|
#endif /* HAVE_SPDIF_POWER */
|
||||||
|
/* Set the appropriate feed for spdif output */
|
||||||
|
#ifdef HAVE_SPDIF_OUT
|
||||||
|
spdif_set_output_source(source
|
||||||
|
IF_SPDIF_POWER_(, global_settings.spdif_enable));
|
||||||
|
#endif /* HAVE_SPDIF_OUT */
|
||||||
|
|
||||||
|
/** Tuner **/
|
||||||
|
#if CONFIG_TUNER
|
||||||
|
/* Switch radio off or on per source and flags. */
|
||||||
|
if (source != AUDIO_SRC_FMRADIO)
|
||||||
|
radio_stop();
|
||||||
|
else if (flags & SRCF_FMRADIO_PAUSED)
|
||||||
|
radio_pause();
|
||||||
|
else
|
||||||
|
radio_start();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set hardware inputs */
|
||||||
|
audio_input_mux(source, flags);
|
||||||
|
} /* audio_set_source */
|
||||||
|
|
||||||
|
#ifdef HAVE_SPDIF_IN
|
||||||
|
/**
|
||||||
|
* Return SPDIF sample rate index in audio_master_sampr_list. Since we base
|
||||||
|
* our reading on the actual SPDIF sample rate (which might be a bit
|
||||||
|
* inaccurate), we round off to the closest sample rate that is supported by
|
||||||
|
* SPDIF.
|
||||||
|
*/
|
||||||
|
int audio_get_spdif_sample_rate(void)
|
||||||
|
{
|
||||||
|
unsigned long measured_rate = spdif_measure_frequency();
|
||||||
|
/* Find which SPDIF sample rate we're closest to. */
|
||||||
|
return round_value_to_list32(measured_rate, audio_master_sampr_list,
|
||||||
|
SAMPR_NUM_FREQ, false);
|
||||||
|
} /* audio_get_spdif_sample_rate */
|
||||||
|
#endif /* HAVE_SPDIF_IN */
|
||||||
|
|
||||||
|
#else /* SIMULATOR */
|
||||||
|
|
||||||
|
/** Sim stubs **/
|
||||||
|
|
||||||
|
#ifdef AUDIO_CPU_BOOST
|
||||||
|
static void audio_cpu_boost(bool state)
|
||||||
|
{
|
||||||
|
(void)state;
|
||||||
|
} /* audio_cpu_boost */
|
||||||
|
#endif /* AUDIO_CPU_BOOST */
|
||||||
|
|
||||||
|
void audio_set_output_source(int source)
|
||||||
|
{
|
||||||
|
(void)source;
|
||||||
|
} /* audio_set_output_source */
|
||||||
|
|
||||||
|
void audio_set_input_source(int source, unsigned flags)
|
||||||
|
{
|
||||||
|
(void)source;
|
||||||
|
(void)flags;
|
||||||
|
} /* audio_set_input_source */
|
||||||
|
|
||||||
|
#ifdef HAVE_SPDIF_IN
|
||||||
|
int audio_get_spdif_sample_rate(void)
|
||||||
|
{
|
||||||
|
return FREQ_44;
|
||||||
|
} /* audio_get_spdif_sample_rate */
|
||||||
|
#endif /* HAVE_SPDIF_IN */
|
||||||
|
|
||||||
|
#endif /* !SIMULATOR */
|
|
@ -693,7 +693,7 @@ static bool dbg_spdif(void)
|
||||||
bool done = false;
|
bool done = false;
|
||||||
bool spdif_src_on;
|
bool spdif_src_on;
|
||||||
int spdif_source = spdif_get_output_source(&spdif_src_on);
|
int spdif_source = spdif_get_output_source(&spdif_src_on);
|
||||||
spdif_set_output_source(AUDIO_SRC_SPDIF, true);
|
spdif_set_output_source(AUDIO_SRC_SPDIF IF_SPDIF_POWER_(, true));
|
||||||
|
|
||||||
lcd_setmargins(0, 0);
|
lcd_setmargins(0, 0);
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
|
@ -844,7 +844,7 @@ static bool dbg_spdif(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdif_set_output_source(spdif_source, spdif_src_on);
|
spdif_set_output_source(spdif_source IF_SPDIF_POWER_(, spdif_src_on));
|
||||||
|
|
||||||
#ifdef HAVE_SPDIF_POWER
|
#ifdef HAVE_SPDIF_POWER
|
||||||
spdif_power_enable(global_settings.spdif_enable);
|
spdif_power_enable(global_settings.spdif_enable);
|
||||||
|
|
|
@ -3301,8 +3301,8 @@ static void audio_stop_playback(void)
|
||||||
|
|
||||||
static void audio_play_start(size_t offset)
|
static void audio_play_start(size_t offset)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_RECORDING) || CONFIG_TUNER
|
#if INPUT_SRC_CAPS != 0
|
||||||
rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Wait for any previously playing audio to flush - TODO: Not necessary? */
|
/* Wait for any previously playing audio to flush - TODO: Not necessary? */
|
||||||
|
|
|
@ -349,11 +349,12 @@ static const struct plugin_api rockbox_api = {
|
||||||
pcm_stop_recording,
|
pcm_stop_recording,
|
||||||
pcm_calculate_rec_peaks,
|
pcm_calculate_rec_peaks,
|
||||||
audio_set_recording_gain,
|
audio_set_recording_gain,
|
||||||
audio_set_output_source,
|
|
||||||
rec_set_source,
|
|
||||||
#endif /* HAVE_RECORDING */
|
#endif /* HAVE_RECORDING */
|
||||||
|
#if INPUT_SRC_CAPS != 0
|
||||||
|
audio_set_output_source,
|
||||||
|
audio_set_input_source,
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* CONFIG_CODEC == SWCODEC */
|
||||||
|
|
||||||
/* playback control */
|
/* playback control */
|
||||||
playlist_amount,
|
playlist_amount,
|
||||||
|
|
|
@ -448,11 +448,12 @@ struct plugin_api {
|
||||||
void (*pcm_stop_recording)(void);
|
void (*pcm_stop_recording)(void);
|
||||||
void (*pcm_calculate_rec_peaks)(int *left, int *right);
|
void (*pcm_calculate_rec_peaks)(int *left, int *right);
|
||||||
void (*audio_set_recording_gain)(int left, int right, int type);
|
void (*audio_set_recording_gain)(int left, int right, int type);
|
||||||
void (*audio_set_output_source)(int monitor);
|
|
||||||
void (*rec_set_source)(int source, unsigned flags);
|
|
||||||
#endif /* HAVE_RECORDING */
|
#endif /* HAVE_RECORDING */
|
||||||
|
#if INPUT_SRC_CAPS != 0
|
||||||
|
void (*audio_set_output_source)(int monitor);
|
||||||
|
void (*audio_set_input_source)(int source, unsigned flags);
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* CONFIG_CODEC == SWCODC */
|
||||||
|
|
||||||
/* playback control */
|
/* playback control */
|
||||||
int (*playlist_amount)(void);
|
int (*playlist_amount)(void);
|
||||||
|
|
|
@ -199,9 +199,9 @@ void play_waveform(void)
|
||||||
rb->audio_stop();
|
rb->audio_stop();
|
||||||
rb->sound_set(SOUND_VOLUME, rb->sound_default(SOUND_VOLUME));
|
rb->sound_set(SOUND_VOLUME, rb->sound_default(SOUND_VOLUME));
|
||||||
|
|
||||||
#ifdef HAVE_RECORDING
|
#ifdef INPUT_SRC_CAPS != 0
|
||||||
/* Select playback */
|
/* Select playback */
|
||||||
rb->rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
|
@ -210,7 +210,7 @@ void play_waveform(void)
|
||||||
|
|
||||||
rb->pcm_set_frequency(rb->hw_freq_sampr[freq]);
|
rb->pcm_set_frequency(rb->hw_freq_sampr[freq]);
|
||||||
|
|
||||||
#ifdef HAVE_RECORDING
|
#ifdef INPUT_SRC_CAPS != 0
|
||||||
/* Recordable targets can play back from other sources */
|
/* Recordable targets can play back from other sources */
|
||||||
rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
|
rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -509,9 +509,9 @@ int radio_screen(void)
|
||||||
|
|
||||||
/* turn on radio */
|
/* turn on radio */
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
rec_set_source(AUDIO_SRC_FMRADIO,
|
audio_set_input_source(AUDIO_SRC_FMRADIO,
|
||||||
(radio_status == FMRADIO_PAUSED) ?
|
(radio_status == FMRADIO_PAUSED) ?
|
||||||
SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
|
SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
|
||||||
#else
|
#else
|
||||||
if (radio_status == FMRADIO_OFF)
|
if (radio_status == FMRADIO_OFF)
|
||||||
radio_start();
|
radio_start();
|
||||||
|
@ -985,7 +985,7 @@ int radio_screen(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
||||||
#else
|
#else
|
||||||
radio_stop();
|
radio_stop();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -547,80 +547,6 @@ int rec_create_directory(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR)
|
|
||||||
|
|
||||||
# ifdef HAVE_SPDIF_REC
|
|
||||||
# ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
||||||
static void rec_boost(bool state)
|
|
||||||
{
|
|
||||||
static bool cpu_boosted = false;
|
|
||||||
|
|
||||||
if (state != cpu_boosted)
|
|
||||||
{
|
|
||||||
cpu_boost(state);
|
|
||||||
cpu_boosted = state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Selects an audio source for recording or playback
|
|
||||||
* powers/unpowers related devices and sets up monitoring.
|
|
||||||
* Here because it calls app code and used only for HAVE_RECORDING atm.
|
|
||||||
* Would like it in pcm_record.c.
|
|
||||||
*
|
|
||||||
* Behaves like a firmware function in that it does not use global settings
|
|
||||||
* to determine the state.
|
|
||||||
*
|
|
||||||
* The order of setting monitoring may need tweaking dependent upon the
|
|
||||||
* selected source to get the smoothest transition.
|
|
||||||
*/
|
|
||||||
void rec_set_source(int source, unsigned flags)
|
|
||||||
{
|
|
||||||
/** Do power up/down of associated device(s) **/
|
|
||||||
|
|
||||||
/** SPDIF **/
|
|
||||||
#ifdef HAVE_SPDIF_REC
|
|
||||||
/* Always boost for SPDIF */
|
|
||||||
rec_boost(source == AUDIO_SRC_SPDIF);
|
|
||||||
#endif /* HAVE_SPDIF_IN */
|
|
||||||
|
|
||||||
#ifdef HAVE_SPDIF_POWER
|
|
||||||
/* Check if S/PDIF output power should be switched off or on. NOTE: assumes
|
|
||||||
both optical in and out is controlled by the same power source, which is
|
|
||||||
the case on H1x0. */
|
|
||||||
spdif_power_enable((source == AUDIO_SRC_SPDIF) ||
|
|
||||||
global_settings.spdif_enable);
|
|
||||||
/* Set the appropriate feed for spdif output */
|
|
||||||
#ifdef HAVE_SPDIF_OUT
|
|
||||||
spdif_set_output_source(source, global_settings.spdif_enable);
|
|
||||||
#endif
|
|
||||||
#else /* !HAVE_SPDIF_POWER */
|
|
||||||
#ifdef HAVE_SPDIF_OUT
|
|
||||||
spdif_set_output_source(source, true);
|
|
||||||
#endif
|
|
||||||
#endif /* !HAVE_SPDIF_POWER */
|
|
||||||
|
|
||||||
/** Tuner **/
|
|
||||||
#if CONFIG_TUNER
|
|
||||||
/* Switch radio off or on per source and flags. */
|
|
||||||
if (source != AUDIO_SRC_FMRADIO)
|
|
||||||
radio_stop();
|
|
||||||
else if (flags & SRCF_FMRADIO_PAUSED)
|
|
||||||
radio_pause();
|
|
||||||
else
|
|
||||||
radio_start();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* set hardware inputs */
|
|
||||||
audio_set_source(source, flags);
|
|
||||||
|
|
||||||
peak_meter_playback((flags & SRCF_RECORDING) == 0);
|
|
||||||
peak_meter_enabled = true;
|
|
||||||
} /* rec_set_source */
|
|
||||||
#endif /* CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) */
|
|
||||||
|
|
||||||
void rec_init_recording_options(struct audio_recording_options *options)
|
void rec_init_recording_options(struct audio_recording_options *options)
|
||||||
{
|
{
|
||||||
options->rec_source = global_settings.rec_source;
|
options->rec_source = global_settings.rec_source;
|
||||||
|
@ -637,6 +563,18 @@ void rec_init_recording_options(struct audio_recording_options *options)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
|
||||||
|
void rec_set_source(int source, unsigned flags)
|
||||||
|
{
|
||||||
|
/* Set audio input source, power up/down devices */
|
||||||
|
audio_set_input_source(source, flags);
|
||||||
|
|
||||||
|
/* Set peakmeters for recording or reset to playback */
|
||||||
|
peak_meter_playback((flags & SRCF_RECORDING) == 0);
|
||||||
|
peak_meter_enabled = true;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
|
||||||
|
|
||||||
void rec_set_recording_options(struct audio_recording_options *options)
|
void rec_set_recording_options(struct audio_recording_options *options)
|
||||||
{
|
{
|
||||||
#if CONFIG_CODEC != SWCODEC
|
#if CONFIG_CODEC != SWCODEC
|
||||||
|
@ -2062,20 +2000,6 @@ void rec_set_source(int source, unsigned flags)
|
||||||
flags = flags;
|
flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SPDIF_IN
|
|
||||||
#ifdef HAVE_SPDIF_POWER
|
|
||||||
void audio_set_spdif_power_setting(bool on)
|
|
||||||
{
|
|
||||||
on = on;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool audio_get_spdif_power_setting(void)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif /* HAVE_SPDIF_POWER */
|
|
||||||
#endif /* HAVE_SPDIF_IN */
|
|
||||||
|
|
||||||
void audio_set_recording_options(struct audio_recording_options *options)
|
void audio_set_recording_options(struct audio_recording_options *options)
|
||||||
{
|
{
|
||||||
options = options;
|
options = options;
|
||||||
|
@ -2088,13 +2012,12 @@ void audio_set_recording_gain(int left, int right, int type)
|
||||||
type = type;
|
type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_set_output_source(int source)
|
void audio_record(const char *filename)
|
||||||
{
|
{
|
||||||
source = source;
|
filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void audio_new_file(const char *filename)
|
||||||
void audio_record(const char *filename)
|
|
||||||
{
|
{
|
||||||
filename = filename;
|
filename = filename;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ int rec_create_directory(void);
|
||||||
extern bool recording_start_automatic;
|
extern bool recording_start_automatic;
|
||||||
|
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
/* handles device powerup and sets audio source */
|
/* handles device powerup, sets audio source and peakmeter mode */
|
||||||
void rec_set_source(int source, unsigned flags);
|
void rec_set_source(int source, unsigned flags);
|
||||||
#endif /* CONFIG_CODEC == SW_CODEC */
|
#endif /* CONFIG_CODEC == SW_CODEC */
|
||||||
|
|
||||||
|
@ -47,4 +47,4 @@ void rec_record(void);
|
||||||
/* creates unique filename and starts recording */
|
/* creates unique filename and starts recording */
|
||||||
void rec_new_file(void);
|
void rec_new_file(void);
|
||||||
|
|
||||||
#endif
|
#endif /* RECORDING_H */
|
||||||
|
|
|
@ -194,12 +194,7 @@ void audio_record(const char *filename);
|
||||||
void audio_stop_recording(void);
|
void audio_stop_recording(void);
|
||||||
void audio_pause_recording(void);
|
void audio_pause_recording(void);
|
||||||
void audio_resume_recording(void);
|
void audio_resume_recording(void);
|
||||||
#if CONFIG_CODEC == SWCODEC
|
|
||||||
static inline void audio_new_file(const char *filename)
|
|
||||||
{ audio_record(filename); }
|
|
||||||
#else
|
|
||||||
void audio_new_file(const char *filename);
|
void audio_new_file(const char *filename);
|
||||||
#endif /* CONFIG_CODEC == SWCODEC */
|
|
||||||
void audio_set_recording_options(struct audio_recording_options *options);
|
void audio_set_recording_options(struct audio_recording_options *options);
|
||||||
void audio_set_recording_gain(int left, int right, int type);
|
void audio_set_recording_gain(int left, int right, int type);
|
||||||
unsigned long audio_recorded_time(void);
|
unsigned long audio_recorded_time(void);
|
||||||
|
@ -211,11 +206,22 @@ unsigned long audio_num_recorded_bytes(void);
|
||||||
bool audio_load_encoder(int afmt);
|
bool audio_load_encoder(int afmt);
|
||||||
void audio_remove_encoder(void);
|
void audio_remove_encoder(void);
|
||||||
unsigned char *audio_get_recording_buffer(size_t *buffer_size);
|
unsigned char *audio_get_recording_buffer(size_t *buffer_size);
|
||||||
void audio_set_source(int source, unsigned flags);
|
|
||||||
void audio_set_output_source(int source);
|
|
||||||
#endif /* CONFIG_CODEC == SWCODEC */
|
#endif /* CONFIG_CODEC == SWCODEC */
|
||||||
|
|
||||||
#endif /* HAVE_RECORDING */
|
#endif /* HAVE_RECORDING */
|
||||||
|
|
||||||
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
/* SWCODEC misc. audio functions */
|
||||||
|
#if INPUT_SRC_CAPS != 0
|
||||||
|
/* audio.c */
|
||||||
|
void audio_set_input_source(int source, unsigned flags);
|
||||||
|
/* audio_input_mux: target-specific implementation used by audio_set_source
|
||||||
|
to set hardware inputs and audio paths */
|
||||||
|
void audio_input_mux(int source, unsigned flags);
|
||||||
|
void audio_set_output_source(int source);
|
||||||
|
#endif /* INPUT_SRC_CAPS */
|
||||||
|
#endif /* CONFIG_CODEC == SWCODEC */
|
||||||
|
|
||||||
#ifdef HAVE_SPDIF_IN
|
#ifdef HAVE_SPDIF_IN
|
||||||
/* returns index into rec_master_sampr_list */
|
/* returns index into rec_master_sampr_list */
|
||||||
int audio_get_spdif_sample_rate(void);
|
int audio_get_spdif_sample_rate(void);
|
||||||
|
|
|
@ -66,6 +66,10 @@
|
||||||
#define HAVE_FMRADIO_IN_(...)
|
#define HAVE_FMRADIO_IN_(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if INPUT_SRC_CAPS != 0 && (INPUT_SRC_CAPS & (INPUT_SRC_CAPS-1)) != 0
|
||||||
|
#define HAVE_MULTI_INPUT_SRC
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_RECORDING
|
#ifdef HAVE_RECORDING
|
||||||
/* Recordable source implies it has the input as well */
|
/* Recordable source implies it has the input as well */
|
||||||
|
|
||||||
|
@ -104,4 +108,9 @@
|
||||||
#else
|
#else
|
||||||
#define HAVE_FMRADIO_REC_(...)
|
#define HAVE_FMRADIO_REC_(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if REC_SRC_CAPS != 0 && (REC_SRC_CAPS & (REC_SRC_CAPS-1)) != 0
|
||||||
|
#define HAVE_MULTI_REC_SRC
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* HAVE_RECORDING */
|
#endif /* HAVE_RECORDING */
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
#ifndef SPDIF_H
|
#ifndef SPDIF_H
|
||||||
#define SPDIF_H
|
#define SPDIF_H
|
||||||
|
|
||||||
|
#ifdef HAVE_SPDIF_POWER
|
||||||
|
#define IF_SPDIF_POWER_(...) __VA_ARGS__
|
||||||
|
#else
|
||||||
|
#define IF_SPDIF_POWER_(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize the S/PDIF driver */
|
/* Initialize the S/PDIF driver */
|
||||||
void spdif_init(void);
|
void spdif_init(void);
|
||||||
/* Return the S/PDIF frequency in herz - unrounded */
|
/* Return the S/PDIF frequency in herz - unrounded */
|
||||||
|
@ -27,7 +33,7 @@ unsigned long spdif_measure_frequency(void);
|
||||||
#ifdef HAVE_SPDIF_OUT
|
#ifdef HAVE_SPDIF_OUT
|
||||||
/* Set the S/PDIF audio feed - Use AUDIO_SRC_* values -
|
/* Set the S/PDIF audio feed - Use AUDIO_SRC_* values -
|
||||||
will be off if not powered or !on */
|
will be off if not powered or !on */
|
||||||
void spdif_set_output_source(int source, bool on);
|
void spdif_set_output_source(int source IF_SPDIF_POWER_(, bool on));
|
||||||
/* Return the last set S/PDIF audio source - literally the last value passed
|
/* Return the last set S/PDIF audio source - literally the last value passed
|
||||||
to spdif_set_monitor regardless of power state */
|
to spdif_set_monitor regardless of power state */
|
||||||
int spdif_get_output_source(bool *src_on);
|
int spdif_get_output_source(bool *src_on);
|
||||||
|
|
|
@ -480,6 +480,14 @@ void audio_record(const char *filename)
|
||||||
logf("audio_record_done");
|
logf("audio_record_done");
|
||||||
} /* audio_record */
|
} /* audio_record */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* audio_record wrapper for API compatibility with HW codec
|
||||||
|
*/
|
||||||
|
void audio_new_file(const char *filename)
|
||||||
|
{
|
||||||
|
audio_record(filename);
|
||||||
|
} /* audio_new_file */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop current recording if recording
|
* Stop current recording if recording
|
||||||
*/
|
*/
|
||||||
|
@ -551,22 +559,6 @@ unsigned long audio_num_recorded_bytes(void)
|
||||||
return num_rec_bytes;
|
return num_rec_bytes;
|
||||||
} /* audio_num_recorded_bytes */
|
} /* audio_num_recorded_bytes */
|
||||||
|
|
||||||
#ifdef HAVE_SPDIF_IN
|
|
||||||
/**
|
|
||||||
* Return SPDIF sample rate index in audio_master_sampr_list. Since we base
|
|
||||||
* our reading on the actual SPDIF sample rate (which might be a bit
|
|
||||||
* inaccurate), we round off to the closest sample rate that is supported by
|
|
||||||
* SPDIF.
|
|
||||||
*/
|
|
||||||
int audio_get_spdif_sample_rate(void)
|
|
||||||
{
|
|
||||||
unsigned long measured_rate = spdif_measure_frequency();
|
|
||||||
/* Find which SPDIF sample rate we're closest to. */
|
|
||||||
return round_value_to_list32(measured_rate, audio_master_sampr_list,
|
|
||||||
SAMPR_NUM_FREQ, false);
|
|
||||||
} /* audio_get_spdif_sample_rate */
|
|
||||||
#endif /* HAVE_SPDIF_IN */
|
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* Functions that execute in the context of pcmrec_thread */
|
/* Functions that execute in the context of pcmrec_thread */
|
||||||
|
@ -1756,7 +1748,7 @@ void enc_set_parameters(struct enc_parameters *params)
|
||||||
fnq_size *= MAX_PATH;
|
fnq_size *= MAX_PATH;
|
||||||
logf("fnq files:%ld", fnq_size / MAX_PATH);
|
logf("fnq files:%ld", fnq_size / MAX_PATH);
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
logf("ab :%08lX", (uintptr_t)audiobuf);
|
logf("ab :%08lX", (uintptr_t)audiobuf);
|
||||||
logf("pcm:%08lX", (uintptr_t)pcm_buffer);
|
logf("pcm:%08lX", (uintptr_t)pcm_buffer);
|
||||||
logf("enc:%08lX", (uintptr_t)enc_buffer);
|
logf("enc:%08lX", (uintptr_t)enc_buffer);
|
||||||
|
|
|
@ -29,7 +29,7 @@ void audio_set_output_source(int source)
|
||||||
source = AUDIO_SRC_PLAYBACK;
|
source = AUDIO_SRC_PLAYBACK;
|
||||||
} /* audio_set_output_source */
|
} /* audio_set_output_source */
|
||||||
|
|
||||||
void audio_set_source(int source, unsigned flags)
|
void audio_input_mux(int source, unsigned flags)
|
||||||
{
|
{
|
||||||
(void)flags;
|
(void)flags;
|
||||||
/* Prevent pops from unneeded switching */
|
/* Prevent pops from unneeded switching */
|
||||||
|
@ -87,6 +87,6 @@ void audio_set_source(int source, unsigned flags)
|
||||||
} /* end switch */
|
} /* end switch */
|
||||||
|
|
||||||
last_source = source;
|
last_source = source;
|
||||||
} /* audio_set_source */
|
} /* audio_input_mux */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ void audio_set_output_source(int source)
|
||||||
set_fiq_status(oldmode);
|
set_fiq_status(oldmode);
|
||||||
} /* audio_set_output_source */
|
} /* audio_set_output_source */
|
||||||
|
|
||||||
void audio_set_source(int source, unsigned flags)
|
void audio_input_mux(int source, unsigned flags)
|
||||||
{
|
{
|
||||||
static int last_source = AUDIO_SRC_PLAYBACK;
|
static int last_source = AUDIO_SRC_PLAYBACK;
|
||||||
static bool last_recording = false;
|
static bool last_recording = false;
|
||||||
|
@ -89,6 +89,4 @@ void audio_set_source(int source, unsigned flags)
|
||||||
} /* end switch */
|
} /* end switch */
|
||||||
|
|
||||||
last_source = source;
|
last_source = source;
|
||||||
} /* audio_set_source */
|
} /* audio_input_mux */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ void audio_set_output_source(int source)
|
||||||
set_irq_level(level);
|
set_irq_level(level);
|
||||||
} /* audio_set_output_source */
|
} /* audio_set_output_source */
|
||||||
|
|
||||||
void audio_set_source(int source, unsigned flags)
|
void audio_input_mux(int source, unsigned flags)
|
||||||
{
|
{
|
||||||
/* Prevent pops from unneeded switching */
|
/* Prevent pops from unneeded switching */
|
||||||
static int last_source = AUDIO_SRC_PLAYBACK;
|
static int last_source = AUDIO_SRC_PLAYBACK;
|
||||||
|
@ -79,5 +79,4 @@ void audio_set_source(int source, unsigned flags)
|
||||||
or_l((1 << 29), &GPIO_FUNCTION);
|
or_l((1 << 29), &GPIO_FUNCTION);
|
||||||
|
|
||||||
last_source = source;
|
last_source = source;
|
||||||
} /* audio_set_source */
|
} /* audio_input_mux */
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ void audio_set_output_source(int source)
|
||||||
set_irq_level(level);
|
set_irq_level(level);
|
||||||
} /* audio_set_output_source */
|
} /* audio_set_output_source */
|
||||||
|
|
||||||
void audio_set_source(int source, unsigned flags)
|
void audio_input_mux(int source, unsigned flags)
|
||||||
{
|
{
|
||||||
/* Prevent pops from unneeded switching */
|
/* Prevent pops from unneeded switching */
|
||||||
static int last_source = AUDIO_SRC_PLAYBACK;
|
static int last_source = AUDIO_SRC_PLAYBACK;
|
||||||
|
@ -109,5 +109,5 @@ void audio_set_source(int source, unsigned flags)
|
||||||
or_l((1 << 29), &GPIO_FUNCTION);
|
or_l((1 << 29), &GPIO_FUNCTION);
|
||||||
|
|
||||||
last_source = source;
|
last_source = source;
|
||||||
} /* audio_set_source */
|
} /* audio_input_mux */
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ void audio_set_output_source(int source)
|
||||||
set_irq_level(level);
|
set_irq_level(level);
|
||||||
} /* audio_set_output_source */
|
} /* audio_set_output_source */
|
||||||
|
|
||||||
void audio_set_source(int source, unsigned flags)
|
void audio_input_mux(int source, unsigned flags)
|
||||||
{
|
{
|
||||||
/* Prevent pops from unneeded switching */
|
/* Prevent pops from unneeded switching */
|
||||||
static int last_source = AUDIO_SRC_PLAYBACK;
|
static int last_source = AUDIO_SRC_PLAYBACK;
|
||||||
|
@ -131,6 +131,4 @@ void audio_set_source(int source, unsigned flags)
|
||||||
or_l(MUX_BIT, &GPIO_FUNCTION);
|
or_l(MUX_BIT, &GPIO_FUNCTION);
|
||||||
|
|
||||||
last_source = source;
|
last_source = source;
|
||||||
} /* audio_set_source */
|
} /* audio_input_mux */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,8 @@ void spdif_power_enable(bool on)
|
||||||
|
|
||||||
#ifndef BOOTLOADER
|
#ifndef BOOTLOADER
|
||||||
/* Make sure the feed is reset */
|
/* Make sure the feed is reset */
|
||||||
spdif_set_output_source(spdif_get_output_source(NULL), true);
|
spdif_set_output_source(spdif_get_output_source(NULL)
|
||||||
|
IF_SPDIF_POWER_(, true));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ void spdif_init(void)
|
||||||
{
|
{
|
||||||
/* PHASECONFIG setup: gain = 3*2^13, source = EBUIN */
|
/* PHASECONFIG setup: gain = 3*2^13, source = EBUIN */
|
||||||
PHASECONFIG = (6 << 3) | (4 << 0);
|
PHASECONFIG = (6 << 3) | (4 << 0);
|
||||||
spdif_set_output_source(AUDIO_SRC_PLAYBACK, true);
|
spdif_set_output_source(AUDIO_SRC_PLAYBACK
|
||||||
|
IF_SPDIF_POWER_(, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the S/PDIF frequency in herz - unrounded */
|
/* Return the S/PDIF frequency in herz - unrounded */
|
||||||
|
|
|
@ -271,7 +271,7 @@ void pcm_init(void)
|
||||||
/* Initialize default register values. */
|
/* Initialize default register values. */
|
||||||
audiohw_init();
|
audiohw_init();
|
||||||
|
|
||||||
audio_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
audio_input_mux(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
||||||
|
|
||||||
audiohw_set_frequency(freq_ent[FPARM_FSEL]);
|
audiohw_set_frequency(freq_ent[FPARM_FSEL]);
|
||||||
coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM);
|
coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM);
|
||||||
|
|
Loading…
Reference in a new issue