rockbox/firmware/export/config_caps.h
Michael Sevakis d37bf24d90 Enable setting of global output samplerate on certain targets.
Replaces the NATIVE_FREQUENCY constant with a configurable frequency.

The user may select 48000Hz if the hardware supports it. The default is
still 44100Hz and the minimum is 44100Hz. The setting is located in the
playback settings, under "Frequency".

"Frequency" was duplicated in english.lang for now to avoid having to
fix every .lang file for the moment and throwing everything out of sync
because of the new play_frequency feature in features.txt. The next
cleanup should combine it with the one included for recording and
generalize the ID label.

If the hardware doesn't support 48000Hz, no setting will be available.

On particular hardware where very high rates are practical and desireable,
the upper bound can be extended by patching.

The PCM mixer can be configured to play at the full hardware frequency
range. The DSP core can configure to the hardware minimum up to the
maximum playback setting (some buffers must be reserved according to
the maximum rate).

If only 44100Hz is supported or possible on a given target for playback,
using the DSP and mixer at other samperates is possible if the hardware
offers them.

Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622
Reviewed-on: http://gerrit.rockbox.org/479
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
2013-07-06 04:22:04 +02:00

152 lines
4.6 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Michael Sevakis
*
* Convert caps masks into HAVE_* defines
*
* 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.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/** INPUTS **/
/* NOTE: Playback is implied in all this. Make sense? :) */
#define SRC_MIC 0
#define SRC_LINEIN 1
#define SRC_SPDIF 2
#define SRC_FMRADIO 3
#define SRC_CAP_MIC (1 << SRC_MIC)
#define SRC_CAP_LINEIN (1 << SRC_LINEIN)
#define SRC_CAP_SPDIF (1 << SRC_SPDIF)
#define SRC_CAP_FMRADIO (1 << SRC_FMRADIO)
/* audio monitor mux sources */
#ifndef INPUT_SRC_CAPS
#define INPUT_SRC_CAPS 0 /* Nothing but playback */
#endif
/* Microphone */
#if (INPUT_SRC_CAPS & SRC_CAP_MIC)
#define HAVE_MIC_IN
#define HAVE_MIC_IN_(...) __VA_ARGS__
#else
#define HAVE_MIC_IN_(...)
#endif
/* Line In */
#if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
#define HAVE_LINE_IN
#define HAVE_LINE_IN_(...) __VA_ARGS__
#else
#define HAVE_LINE_IN_(...)
#endif
/* S/PDIF */
#if (INPUT_SRC_CAPS & SRC_CAP_SPDIF)
#define HAVE_SPDIF_IN
#define HAVE_SPDIF_IN_(...) __VA_ARGS__
#else
#define HAVE_SPDIF_IN_(...)
#endif
/* FM Radio */
#if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
#define HAVE_FMRADIO_IN
#define HAVE_FMRADIO_IN_(...) __VA_ARGS__
#else
#define HAVE_FMRADIO_IN_(...)
#endif
#if INPUT_SRC_CAPS != 0 && (INPUT_SRC_CAPS & (INPUT_SRC_CAPS-1)) != 0
#define HAVE_MULTI_INPUT_SRC
#endif
#ifdef HAVE_RECORDING
/* Recordable source implies it has the input as well */
/* For now there's no restrictions on any targets with which inputs
are recordable so define them as equivalent - if they do differ,
special handling is needed right now. */
#ifndef REC_SRC_CAPS
#define REC_SRC_CAPS INPUT_SRC_CAPS
#endif
/* Microphone */
#if (REC_SRC_CAPS & SRC_CAP_MIC)
#define HAVE_MIC_REC
#define HAVE_MIC_REC_(...) __VA_ARGS__
#else
#define HAVE_MIC_REC_(...)
#endif
/* Line In */
#if (REC_SRC_CAPS & SRC_CAP_LINEIN)
#define HAVE_LINE_REC
#define HAVE_LINE_REC_(...) __VA_ARGS__
#else
#define HAVE_LINE_REC_(...)
#endif
/* S/PDIF */
#if (REC_SRC_CAPS & SRC_CAP_SPDIF)
#define HAVE_SPDIF_REC
#define HAVE_SPDIF_REC_(...) __VA_ARGS__
#else
#define HAVE_SPDIF_REC_(...)
#endif
/* FM Radio */
#if (REC_SRC_CAPS & SRC_CAP_FMRADIO)
#define HAVE_FMRADIO_REC
#define HAVE_FMRADIO_REC_(...) __VA_ARGS__
#else
#define HAVE_FMRADIO_REC_(...)
#endif
#if REC_SRC_CAPS != 0 && (REC_SRC_CAPS & (REC_SRC_CAPS-1)) != 0
#define HAVE_MULTI_REC_SRC
#endif
#endif /* HAVE_RECORDING */
/* Samplerate config */
#define PCM_SAMPR_CONFIG_ONLY /* no C code */
#include "pcm_sampr.h"
#undef PCM_SAMPR_CONFIG_ONLY
#define PLAY_SAMPR_CAPS (HW_SAMPR_CAPS & (SAMPR_CAP_44 | SAMPR_CAP_48))
/**
* PLAY_SAMPR_MIN: The minimum allowable samplerate for global playback.
* Music won't play at a lower rate.
* PLAY_SAMPR_MAX: The maximum allowable samplerate for global playback.
* Music won't play at a faster rate.
* PLAY_SAMPR_DEFAULT: The default samplerate, unless configured otherwise.
* PLAY_SAMPR_HW_MIN: The minimum allowable rate for some subsystems such
* as the DSP core. DSP never exceeds *MAX to lessen
* buffer allocation demands and overhead.
*/
#if PLAY_SAMPR_CAPS & (PLAY_SAMPR_CAPS - 1)
#define HAVE_PLAY_FREQ
# define PLAY_SAMPR_MIN SAMPR_44
# define PLAY_SAMPR_MAX SAMPR_48
# define PLAY_SAMPR_DEFAULT SAMPR_44
# define PLAY_SAMPR_HW_MIN HW_SAMPR_MIN
#elif PLAY_SAMPR_CAPS & SAMPR_CAP_44
# define PLAY_SAMPR_MIN SAMPR_44
# define PLAY_SAMPR_MAX SAMPR_44
# define PLAY_SAMPR_DEFAULT SAMPR_44
# define PLAY_SAMPR_HW_MIN HW_SAMPR_MIN
#elif PLAY_SAMPR_CAPS & SAMPR_CAP_48
# define PLAY_SAMPR_MIN SAMPR_48
# define PLAY_SAMPR_MAX SAMPR_48
# define PLAY_SAMPR_DEFAULT SAMPR_48
# define PLAY_SAMPR_HW_MIN HW_SAMPR_MIN
#endif