mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
* Move DSP_CALLBACK_* enum to sound.h
* Add software based volume control for a certain range (SW_VOLUME_MIN -> SW_VOLUME_MAX) * Make Onda VX747 use it * Don't change volume or frequency in Ingenic Jz4740 codec driver when they're already set git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22106 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1ace06a67d
commit
3c7c79189e
6 changed files with 52 additions and 32 deletions
14
apps/dsp.c
14
apps/dsp.c
|
@ -890,6 +890,15 @@ static void set_gain(struct dsp_config *dsp)
|
||||||
(long) (((int64_t) dsp->data.gain * eq_precut) >> 24);
|
(long) (((int64_t) dsp->data.gain * eq_precut) >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
||||||
|
if (global_settings.volume < SW_VOLUME_MAX ||
|
||||||
|
global_settings.volume > SW_VOLUME_MIN)
|
||||||
|
{
|
||||||
|
int vol_gain = get_replaygain_int(global_settings.volume * 100);
|
||||||
|
dsp->data.gain = (long) (((int64_t) dsp->data.gain * vol_gain) >> 24);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (dsp->data.gain == DEFAULT_GAIN)
|
if (dsp->data.gain == DEFAULT_GAIN)
|
||||||
{
|
{
|
||||||
dsp->data.gain = 0;
|
dsp->data.gain = 0;
|
||||||
|
@ -1149,6 +1158,11 @@ int dsp_callback(int msg, intptr_t param)
|
||||||
case DSP_CALLBACK_SET_TREBLE:
|
case DSP_CALLBACK_SET_TREBLE:
|
||||||
treble = param;
|
treble = param;
|
||||||
break;
|
break;
|
||||||
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
||||||
|
case DSP_CALLBACK_SET_SW_VOLUME:
|
||||||
|
set_gain(&AUDIO_DSP);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
case DSP_CALLBACK_SET_CHANNEL_CONFIG:
|
case DSP_CALLBACK_SET_CHANNEL_CONFIG:
|
||||||
dsp_set_channel_config(param);
|
dsp_set_channel_config(param);
|
||||||
|
|
|
@ -56,14 +56,6 @@ enum
|
||||||
DSP_CROSSFEED
|
DSP_CROSSFEED
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
DSP_CALLBACK_SET_PRESCALE = 0,
|
|
||||||
DSP_CALLBACK_SET_BASS,
|
|
||||||
DSP_CALLBACK_SET_TREBLE,
|
|
||||||
DSP_CALLBACK_SET_CHANNEL_CONFIG,
|
|
||||||
DSP_CALLBACK_SET_STEREO_WIDTH
|
|
||||||
};
|
|
||||||
|
|
||||||
struct dsp_config;
|
struct dsp_config;
|
||||||
|
|
||||||
int dsp_process(struct dsp_config *dsp, char *dest,
|
int dsp_process(struct dsp_config *dsp, char *dest,
|
||||||
|
|
|
@ -139,6 +139,14 @@
|
||||||
/* has no tone controls, so we use the software ones */
|
/* has no tone controls, so we use the software ones */
|
||||||
#define HAVE_SW_TONE_CONTROLS
|
#define HAVE_SW_TONE_CONTROLS
|
||||||
|
|
||||||
|
/* has no volume control, so we use the software ones */
|
||||||
|
#define HAVE_SW_VOLUME_CONTROL
|
||||||
|
|
||||||
|
/* software controlled volume ranges from -73 -> 0 dB, other than that
|
||||||
|
is controlled by hardware */
|
||||||
|
#define SW_VOLUME_MIN -73
|
||||||
|
#define SW_VOLUME_MAX 0
|
||||||
|
|
||||||
/* define the bitmask of hardware sample rates */
|
/* define the bitmask of hardware sample rates */
|
||||||
#define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \
|
#define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \
|
||||||
SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
|
SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
|
||||||
|
|
|
@ -24,6 +24,19 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <audiohw.h>
|
#include <audiohw.h>
|
||||||
|
|
||||||
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
enum {
|
||||||
|
DSP_CALLBACK_SET_PRESCALE = 0,
|
||||||
|
DSP_CALLBACK_SET_BASS,
|
||||||
|
DSP_CALLBACK_SET_TREBLE,
|
||||||
|
DSP_CALLBACK_SET_CHANNEL_CONFIG,
|
||||||
|
DSP_CALLBACK_SET_STEREO_WIDTH,
|
||||||
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
||||||
|
DSP_CALLBACK_SET_SW_VOLUME,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void sound_set_type(int value);
|
typedef void sound_set_type(int value);
|
||||||
|
|
||||||
const char *sound_unit(int setting);
|
const char *sound_unit(int setting);
|
||||||
|
|
|
@ -158,16 +158,6 @@ sound_set_type* sound_get_fn(int setting)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
/* Copied from dsp.h, nasty nasty, but we don't want to include dsp.h */
|
|
||||||
|
|
||||||
enum {
|
|
||||||
DSP_CALLBACK_SET_PRESCALE = 0,
|
|
||||||
DSP_CALLBACK_SET_BASS,
|
|
||||||
DSP_CALLBACK_SET_TREBLE,
|
|
||||||
DSP_CALLBACK_SET_CHANNEL_CONFIG,
|
|
||||||
DSP_CALLBACK_SET_STEREO_WIDTH
|
|
||||||
};
|
|
||||||
|
|
||||||
static int (*dsp_callback)(int, intptr_t) = NULL;
|
static int (*dsp_callback)(int, intptr_t) = NULL;
|
||||||
|
|
||||||
void sound_set_dsp_callback(int (*func)(int, intptr_t))
|
void sound_set_dsp_callback(int (*func)(int, intptr_t))
|
||||||
|
@ -251,6 +241,10 @@ static void set_prescaled_volume(void)
|
||||||
r += ((r - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
|
r += ((r - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
||||||
|
dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_CODEC == MAS3507D
|
#if CONFIG_CODEC == MAS3507D
|
||||||
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
|
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
|
||||||
#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
|
#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
const struct sound_settings_info audiohw_settings[] = {
|
const struct sound_settings_info audiohw_settings[] = {
|
||||||
[SOUND_VOLUME] = {"dB", 0, 2, 0, 6, 0},
|
/* HAVE_SW_VOLUME_CONTROL */
|
||||||
|
[SOUND_VOLUME] = {"dB", 0, 1, SW_VOLUME_MIN, 6, 0},
|
||||||
/* HAVE_SW_TONE_CONTROLS */
|
/* HAVE_SW_TONE_CONTROLS */
|
||||||
[SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
|
[SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
|
||||||
[SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
|
[SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
|
||||||
|
@ -79,7 +80,7 @@ static void i2s_codec_init(void)
|
||||||
|
|
||||||
REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_SUSPD | ICDC_CDCCR1_RST);
|
REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_SUSPD | ICDC_CDCCR1_RST);
|
||||||
|
|
||||||
REG_ICDC_CDCCR2 = ( ICDC_CDCCR2_AINVOL(14) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_44)
|
REG_ICDC_CDCCR2 = ( ICDC_CDCCR2_AINVOL(23) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_44)
|
||||||
| ICDC_CDCCR2_HPVOL(ICDC_CDCCR2_HPVOL_0));
|
| ICDC_CDCCR2_HPVOL(ICDC_CDCCR2_HPVOL_0));
|
||||||
|
|
||||||
mdelay(15);
|
mdelay(15);
|
||||||
|
@ -287,9 +288,14 @@ void audiohw_init(void)
|
||||||
|
|
||||||
void audiohw_set_volume(int v)
|
void audiohw_set_volume(int v)
|
||||||
{
|
{
|
||||||
|
if(v >= 0)
|
||||||
|
{
|
||||||
/* 0 <= v <= 60 */
|
/* 0 <= v <= 60 */
|
||||||
unsigned int codec_volume = v / 20;
|
unsigned int codec_volume = ICDC_CDCCR2_HPVOL(v / 20);
|
||||||
REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_HPVOL(0x3)) | ICDC_CDCCR2_HPVOL(codec_volume);
|
|
||||||
|
if((REG_ICDC_CDCCR2 & ICDC_CDCCR2_HPVOL(0x3)) != codec_volume)
|
||||||
|
REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_HPVOL(0x3)) | codec_volume;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_frequency(int freq)
|
void audiohw_set_frequency(int freq)
|
||||||
|
@ -329,6 +335,7 @@ void audiohw_set_frequency(int freq)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((REG_ICDC_CDCCR2 & ICDC_CDCCR2_SMPR(0xF)) != speed)
|
||||||
REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_SMPR(0xF)) | speed;
|
REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_SMPR(0xF)) | speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,20 +363,16 @@ void audio_input_mux(int source, unsigned flags)
|
||||||
case AUDIO_SRC_PLAYBACK:
|
case AUDIO_SRC_PLAYBACK:
|
||||||
audio_channels = 2;
|
audio_channels = 2;
|
||||||
if(source != last_source)
|
if(source != last_source)
|
||||||
{
|
|
||||||
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_ELININ | ICDC_CDCCR1_EMIC | ICDC_CDCCR1_EADC | ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_HPMUTE))
|
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_ELININ | ICDC_CDCCR1_EMIC | ICDC_CDCCR1_EADC | ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_HPMUTE))
|
||||||
| (ICDC_CDCCR1_EDAC | ICDC_CDCCR1_SW2ON);
|
| (ICDC_CDCCR1_EDAC | ICDC_CDCCR1_SW2ON);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if INPUT_SRC_CAPS & SRC_CAP_MIC
|
#if INPUT_SRC_CAPS & SRC_CAP_MIC
|
||||||
case AUDIO_SRC_MIC: /* recording only */
|
case AUDIO_SRC_MIC: /* recording only */
|
||||||
audio_channels = 1;
|
audio_channels = 1;
|
||||||
if(source != last_source)
|
if(source != last_source)
|
||||||
{
|
|
||||||
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_ELININ | ICDC_CDCCR1_EDAC | ICDC_CDCCR1_SW2ON | ICDC_CDCCR1_HPMUTE))
|
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_ELININ | ICDC_CDCCR1_EDAC | ICDC_CDCCR1_SW2ON | ICDC_CDCCR1_HPMUTE))
|
||||||
| (ICDC_CDCCR1_EADC | ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_EMIC);
|
| (ICDC_CDCCR1_EADC | ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_EMIC);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -383,15 +386,11 @@ void audio_input_mux(int source, unsigned flags)
|
||||||
last_recording = recording;
|
last_recording = recording;
|
||||||
|
|
||||||
if(recording)
|
if(recording)
|
||||||
{
|
|
||||||
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_EMIC | ICDC_CDCCR1_EDAC | ICDC_CDCCR1_SW2ON | ICDC_CDCCR1_HPMUTE))
|
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_EMIC | ICDC_CDCCR1_EDAC | ICDC_CDCCR1_SW2ON | ICDC_CDCCR1_HPMUTE))
|
||||||
| (ICDC_CDCCR1_EADC | ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_ELININ);
|
| (ICDC_CDCCR1_EADC | ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_ELININ);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_EMIC | ICDC_CDCCR1_EDAC | ICDC_CDCCR1_EADC |
|
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_EMIC | ICDC_CDCCR1_EDAC | ICDC_CDCCR1_EADC |
|
||||||
ICDC_CDCCR1_SW2ON | ICDC_CDCCR1_HPMUTE)) | (ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_ELININ);
|
ICDC_CDCCR1_SW2ON | ICDC_CDCCR1_HPMUTE)) | (ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_ELININ);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
} /* end switch */
|
} /* end switch */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue