Remove lots of simulator-speficic #ifdef'ing in sound.c to allow for DSP effects in the sims, e.g. for bass and treble (targets that do those effects in HW don't simulate using dsp).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25719 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2010-04-25 22:54:58 +00:00
parent 5185d9e30a
commit 668bd3445e
5 changed files with 92 additions and 130 deletions

View file

@ -65,6 +65,20 @@
#include "ak4537.h"
#endif
#define ONE_DB 10
#if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
#warning define for VOLUME_MIN and VOLUME_MAX is missing
#define VOLUME_MIN -700
#define VOLUME_MAX 0
#endif
/* volume/balance/treble/bass interdependency main part */
#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
/* convert caps into defines */
#ifdef AUDIOHW_CAPS
#if (AUDIOHW_CAPS & TREBLE_CAP)

View file

@ -24,6 +24,7 @@
#include <inttypes.h>
#include <audiohw.h>
#if CONFIG_CODEC == SWCODEC
enum {
DSP_CALLBACK_SET_PRESCALE = 0,

View file

@ -69,9 +69,7 @@ static void (*callback_for_more)(unsigned char**, size_t*);
#define MAX_ID3_TAGS (1<<4) /* Must be power of 2 */
#define MAX_ID3_TAGS_MASK (MAX_ID3_TAGS - 1)
#ifndef SIMULATOR
bool audio_is_initialized = false;
#endif
/* FIX: this code pretty much assumes a MAS */
@ -353,6 +351,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
(void)mdb_shape;
(void)mdb_enable;
(void)superbass;
audio_is_initialized = true;
#else
#if CONFIG_CODEC == MAS3507D
unsigned long val;

View file

@ -25,9 +25,9 @@
#include "sound.h"
#include "logf.h"
#include "system.h"
#ifndef SIMULATOR
#include "i2c.h"
#include "mas.h"
#include "mas.h"
#ifndef SIMULATOR
#if CONFIG_CPU == PNX0101
#include "pnx0101.h"
#endif
@ -41,27 +41,10 @@
* find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble
*/
#define ONE_DB 10
#if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
#warning define for VOLUME_MIN and VOLUME_MAX is missing
#define VOLUME_MIN -700
#define VOLUME_MAX 0
#endif
/* volume/balance/treble/bass interdependency main part */
#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
#ifndef SIMULATOR
extern bool audio_is_initialized;
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
extern unsigned long shadow_io_control_main;
extern unsigned shadow_codec_reg0;
#endif
#endif /* SIMULATOR */
#ifdef SIMULATOR
extern void audiohw_set_volume(int value);
/* dummy for sim */
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25},
@ -90,7 +73,7 @@ const struct sound_settings_info audiohw_settings[] = {
[SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90},
[SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0},
[SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0},
#endif
#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
};
#endif
@ -142,7 +125,7 @@ static sound_set_type * const sound_set_fns[] =
[SOUND_MDB_SHAPE] = sound_set_mdb_shape,
[SOUND_MDB_ENABLE] = sound_set_mdb_enable,
[SOUND_SUPERBASS] = sound_set_superbass,
#endif
#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
[SOUND_BASS_CUTOFF] = sound_set_bass_cutoff,
#endif
@ -166,7 +149,6 @@ void sound_set_dsp_callback(int (*func)(int, intptr_t))
}
#endif
#ifndef SIMULATOR
#if CONFIG_CODEC == MAS3507D
/* convert tenth of dB volume (-780..+180) to dac3550 register value */
static int tenthdb2reg(int db)
@ -248,6 +230,7 @@ static void set_prescaled_volume(void)
dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0);
#endif
#ifndef SIMULATOR
#if CONFIG_CODEC == MAS3507D
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
@ -265,13 +248,13 @@ static void set_prescaled_volume(void)
#elif defined(HAVE_JZ4740_CODEC)
audiohw_set_volume(current_volume);
#endif
#else /* SIMULATOR */
audiohw_set_volume(current_volume);
#endif /* !SIMULATOR */
}
#endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */
#endif /* !SIMULATOR */
#ifndef SIMULATOR
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
unsigned long mdb_shape_shadow = 0;
unsigned long loudness_shadow = 0;
@ -398,7 +381,7 @@ void sound_set_treble_cutoff(int value)
}
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F))
void sound_set_loudness(int value)
{
if(!audio_is_initialized)
@ -486,95 +469,6 @@ void sound_set_superbass(int value)
}
#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
#else /* SIMULATOR */
int sim_volume;
void sound_set_volume(int value)
{
/* 128 is SDL_MIX_MAXVOLUME */
sim_volume = 128 * (value - VOLUME_MIN / 10) / (VOLUME_RANGE / 10);
}
void sound_set_balance(int value)
{
(void)value;
}
void sound_set_bass(int value)
{
(void)value;
}
void sound_set_treble(int value)
{
(void)value;
}
void sound_set_channels(int value)
{
(void)value;
}
void sound_set_stereo_width(int value)
{
(void)value;
}
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
void sound_set_loudness(int value)
{
(void)value;
}
void sound_set_avc(int value)
{
(void)value;
}
void sound_set_mdb_strength(int value)
{
(void)value;
}
void sound_set_mdb_harmonics(int value)
{
(void)value;
}
void sound_set_mdb_center(int value)
{
(void)value;
}
void sound_set_mdb_shape(int value)
{
(void)value;
}
void sound_set_mdb_enable(int value)
{
(void)value;
}
void sound_set_superbass(int value)
{
(void)value;
}
#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
#if defined(HAVE_WM8758) || defined(HAVE_WM8985)
void sound_set_bass_cutoff(int value)
{
(void) value;
}
void sound_set_treble_cutoff(int value)
{
(void) value;
}
#endif /* HAVE_WM8758 */
#endif /* SIMULATOR */
void sound_set(int setting, int value)
{
sound_set_type* sound_set_val = sound_get_fn(setting);
@ -691,13 +585,19 @@ int sound_val2phys(int setting, int value)
#endif /* !defined(HAVE_AS3514) || defined(SIMULATOR) */
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
#ifndef SIMULATOR
/* This function works by telling the decoder that we have another
crystal frequency than we actually have. It will adjust its internal
parameters and the result is that the audio is played at another pitch.
The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h)
*/
#ifdef SIMULATOR
static
#else
extern
#endif
unsigned long shadow_io_control_main;
static int last_pitch = PITCH_SPEED_100;
void sound_set_pitch(int32_t pitch)
@ -723,15 +623,4 @@ int32_t sound_get_pitch(void)
{
return last_pitch;
}
#else /* SIMULATOR */
void sound_set_pitch(int32_t pitch)
{
(void)pitch;
}
int32_t sound_get_pitch(void)
{
return PITCH_SPEED_100;
}
#endif /* SIMULATOR */
#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */

View file

@ -27,11 +27,15 @@
#include "debug.h"
#include "kernel.h"
#include "sound.h"
#include "audiohw.h"
#include "pcm.h"
#include "pcm_sampr.h"
#include "SDL.h"
static int sim_volume = 0;
#if CONFIG_CODEC == SWCODEC
static int cvt_status = -1;
static Uint8* pcm_data;
@ -347,3 +351,58 @@ void pcm_play_dma_init(void)
void pcm_postinit(void)
{
}
#endif /* CONFIG_CODEC == SWCODEC */
/**
* Audio Hardware api. Make them do nothing as we cannot properly simulate with
* SDL. if we used DSP we would run code that doesn't actually run on the target
**/
void audiohw_set_volume(int volume)
{
sim_volume = SDL_MIX_MAXVOLUME * ((volume - VOLUME_MIN) / 10) / (VOLUME_RANGE / 10);
}
#if defined(AUDIOHW_HAVE_PRESCALER)
void audiohw_set_prescaler(int value) { (void)value; }
#endif
#if defined(AUDIOHW_HAVE_BALANCE)
void audiohw_set_balance(int value) { (void)value; }
#endif
#if defined(AUDIOHW_HAVE_BASS)
void audiohw_set_bass(int value) { (void)value; }
#endif
#if defined(AUDIOHW_HAVE_TREBLE)
void audiohw_set_treble(int value) { (void)value; }
#endif
#if CONFIG_CODEC != SWCODEC
void audiohw_set_channel(int value) { (void)value; }
void audiohw_set_stereo_width(int value){ (void)value; }
#endif
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
void audiohw_set_bass_cutoff(value) { (void)value; }
#endif
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
void audiohw_set_treble_cutoff(value) { (void)value; }
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
int mas_codec_readreg(int reg)
{
(void)reg;
return 0;
}
int mas_codec_writereg(int reg, unsigned int val)
{
(void)reg;
(void)val;
return 0;
}
int mas_writemem(int bank, int addr, const unsigned long* src, int len)
{
(void)bank;
(void)addr;
(void)src;
(void)len;
return 0;
}
#endif