Do some cleanup, adjustment and a couple fixes to recent sound changes.

* SOUND_x enum can be generated by audiohw_settings.h along with settings
entries and sound_val2phys.

* VOLUME_MIN and VOLUME_MAX are no longer necessary within sound.c. If
you need them, they are for target-defined purposes.

* Fix up SDL volume implementation in sdl.c. Move sim volume calculation
code to pcm-sdl.c.

* Min trigger tresholds were based upon VOLUME_MIN for some reason.
These setting have nothing to do with playback volume. Since it is no
longer present, set these at -89dB which is the minimum peak meter
sensitivity setting.

* Fix an oversight in wm8758.c. I forgot to add the dB->register
conversion to audiohw_set_volume.

Change-Id: Ie1df33f1793eee75e6793f16bc7bddd16edb7f75
This commit is contained in:
Michael Sevakis 2013-04-20 04:06:13 -04:00
parent 91b33d5a3e
commit e61e9c61d0
43 changed files with 170 additions and 307 deletions

View File

@ -1355,11 +1355,11 @@ const struct settings_list settings[] = {
#endif /* CONFIG_CODEC == SWCODEC */
/* values for the trigger */
INT_SETTING(F_RECSETTING, rec_start_thres_db, LANG_RECORD_START_THRESHOLD, -35,
"trigger start threshold dB", UNIT_DB, VOLUME_MIN/10, 0, 1, NULL, NULL, NULL),
"trigger start threshold dB", UNIT_DB, -89, 0, 1, NULL, NULL, NULL),
INT_SETTING(F_RECSETTING, rec_start_thres_linear, LANG_RECORD_START_THRESHOLD, 5,
"trigger start threshold linear", UNIT_PERCENT, 0, 100, 1, NULL, NULL, NULL),
INT_SETTING(F_RECSETTING, rec_stop_thres_db, LANG_RECORD_STOP_THRESHOLD, -45,
"trigger stop threshold dB", UNIT_DB, VOLUME_MIN/10, 0, 1, NULL, NULL, NULL),
"trigger stop threshold dB", UNIT_DB, -89, 0, 1, NULL, NULL, NULL),
INT_SETTING(F_RECSETTING, rec_stop_thres_linear, LANG_RECORD_STOP_THRESHOLD, 10,
"trigger stop threshold linear", UNIT_PERCENT, 0, 100, 1, NULL, NULL, NULL),
TABLE_SETTING(F_RECSETTING, rec_start_duration, LANG_MIN_DURATION, 0,

View File

@ -37,17 +37,17 @@ static char volume_left = 0, volume_right = 0;
static int vol_tenthdb2hw(int db)
{
/* 0 to -63.0dB in 1dB steps, aic3x can goto -63.5 in 0.5dB steps */
if (db < VOLUME_MIN)
if (db <= -640)
{
return 0x7E;
}
else if (db >= VOLUME_MAX)
else if (db >= 0)
{
return 0x00;
}
else
{
return (-((db)/5)); /* VOLUME_MIN is negative */
return (-((db)/5));
}
}

View File

@ -67,9 +67,9 @@ static void codec_set_active(int active)
/* convert tenth of dB volume (-1270..0) to master volume register value */
static int vol_tenthdb2hw(int db)
{
if (db < VOLUME_MIN)
if (db <= -1280)
return 0xff; /* mute */
else if (db >= VOLUME_MAX)
else if (db >= 0)
return 0x00;
else
return ((-db)/5);

View File

@ -31,6 +31,16 @@
#include "i2s.h"
#include "ascodec.h"
#if CONFIG_CPU == AS3525v2
/* Headphone volume goes from -81.0 ... +6dB */
#define VOLUME_MIN -820
#define VOLUME_MAX 60
#else
/* Headphone volume goes from -73.5 ... +6dB */
#define VOLUME_MIN -740
#define VOLUME_MAX 60
#endif
/*
* This drivers supports:
* as3514 , as used in the PP targets
@ -99,13 +109,12 @@ static void as3514_write_masked(unsigned int reg, unsigned int bits,
/* convert tenth of dB volume to master volume register value */
static int vol_tenthdb2hw(int db)
{
/* +6 to -73.5dB (or -81.0 dB) in 1.5dB steps == 53 (or 58) levels */
if (db < VOLUME_MIN) {
if (db <= VOLUME_MIN) {
return 0x0;
} else if (db > VOLUME_MAX) {
return (VOLUME_MAX-VOLUME_MIN)/15;
return (VOLUME_MAX - VOLUME_MIN) / 15;
} else {
return((db-VOLUME_MIN)/15); /* VOLUME_MIN is negative */
return (db - VOLUME_MIN) / 15;
}
}

View File

@ -38,7 +38,7 @@ static int vol_tenthdb2hw(int db)
/* 0001100 == +12dB (0xc) */
/* 0000000 == 0dB (0x0) */
/* 1000100 == -60dB (0x44, this is actually -58dB) */
if (db < VOLUME_MIN) return HPACTL_HPAMUTE;
if (db <= -600) return HPACTL_HPAMUTE;
return (db / 10) & HPACTL_HPAVOL_MASK;
}

View File

@ -40,9 +40,9 @@ void audiohw_set_frequency(int fsel)
#ifdef HAVE_SW_VOLUME_CONTROL
void audiohw_set_volume(int vol_l, int vol_r)
{
/* SW volume for <= 1.0 gain, HW at unity, < VOLUME_MIN == MUTE */
int sw_volume_l = vol_l < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_l, 0);
int sw_volume_r = vol_r < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_r, 0);
/* SW volume for <= 1.0 gain, HW at unity, <= DUMMY_VOLUME_MIN == MUTE */
int sw_volume_l = vol_l <= DUMMY_VOLUME_MIN ? PCM_MUTE_LEVEL : vol_l;
int sw_volume_r = vol_r <= DUMMY_VOLUME_MIN ? PCM_MUTE_LEVEL : vol_r;
pcm_set_master_volume(sw_volume_l, sw_volume_r);
}
#endif /* HAVE_SW_VOLUME_CONTROL */

View File

@ -58,7 +58,7 @@ static int vol_tenthdb2hw(int tdb)
* depending on gain region.
*/
if (tdb < VOLUME_MIN)
if (tdb <= -340)
return 32;
else if (tdb < -115)
return -(((tdb + 115)/20) - 20); /* 2.0 dB steps */

View File

@ -23,6 +23,12 @@
#include "config.h"
#include "sound.h"
#include "pcm_sampr.h"
#if CONFIG_CODEC == SWCODEC
#include "fixedpoint.h"
#ifdef HAVE_SW_VOLUME_CONTROL
#include "pcm_sw_volume.h"
#endif
#endif
/**
* Audio Hardware api. Make them do nothing as we cannot properly simulate with
@ -30,8 +36,6 @@
**/
#ifdef HAVE_SW_VOLUME_CONTROL
#include "pcm_sw_volume.h"
void audiohw_set_volume(int vol_l, int vol_r)
{
pcm_set_master_volume(vol_l, vol_r);
@ -39,21 +43,13 @@ void audiohw_set_volume(int vol_l, int vol_r)
#else /* ndef HAVE_SW_VOLUME_CONTROL */
extern void pcm_set_mixer_volume(int);
void audiohw_set_volume(int volume)
{
#if CONFIG_CODEC == SWCODEC
#if !(CONFIG_PLATFORM & PLATFORM_MAEMO5)
if (volume < VOLUME_MIN)
volume = 0;
else
volume = SDL_MIX_MAXVOLUME * (volume - VOLUME_MIN + ONE_DB) /
(VOLUME_RANGE + ONE_DB);
#endif /* !(CONFIG_PLATFORM & PLATFORM_MAEMO5) */
extern void pcm_set_mixer_volume(int volume);
pcm_set_mixer_volume(volume);
#endif /* CONFIG_CODEC == SWCODEC */
#endif
(void)volume;
}
#endif /* HAVE_SW_VOLUME_CONTROL */

View File

@ -40,7 +40,7 @@ static int vol_tenthdb2hw(int db)
/* 0110000 == -73dB (0x30) */
/* 0101111 == mute (0x2f) */
if (db < VOLUME_MIN) {
if (db <= -740) {
return 0x2f;
} else {
return((db/10)+73+0x30);

View File

@ -34,12 +34,12 @@ static bool is_muted = false;
static int vol_tenthdb2hw(int db)
{
/* 0 to -63.0dB in 1dB steps, tsc2100 can goto -63.5 in 0.5dB steps */
if (db < VOLUME_MIN) {
if (db <= -640) {
return 0x7E;
} else if (db >= VOLUME_MAX) {
} else if (db >= 0) {
return 0x00;
} else {
return(-((db)/5)); /* VOLUME_MIN is negative */
return(-((db)/5));
}
}

View File

@ -31,7 +31,7 @@
/* convert tenth of dB volume (-600..0) to volume register value */
static int vol_tenthdb2hw(int db)
{
if (db < -600)
if (db <= -610)
return 63;
else /* 1 dB steps */
return -(db / 10) + 1;

View File

@ -101,7 +101,7 @@ static int vol_tenthdb2hw(int db)
/* 1111001 == 0dB (0x79) */
/* 0110000 == -73dB (0x30) */
/* 0101111 == mute (0x2f) */
if (db < VOLUME_MIN) {
if (db <= -740) {
return 0x2f;
} else {
return((db/10)+0x30+73);

View File

@ -117,7 +117,7 @@ static int vol_tenthdb2hw(int db)
/* 1111001 == 0dB (0x79) */
/* 0110000 == -73dB (0x30) */
/* 0101111..0000000 == mute (<= 0x2f) */
if (db < VOLUME_MIN)
if (db <= -740)
return 0x0;
else
return (db / 10) + 73 + 0x30;

View File

@ -38,7 +38,7 @@ static unsigned short eq1_reg = EQ1_EQ3DMODE | EQ_GAIN_VALUE(0);
static unsigned short eq5_reg = EQ_GAIN_VALUE(0);
/* convert tenth of dB volume (-89..6) to master volume register value */
int tenthdb2master(int db)
static int vol_tenthdb2hw(int db)
{
/* att DAC AMP result
+6dB 0 +6 96
@ -47,10 +47,10 @@ int tenthdb2master(int db)
-58dB -1 -57 32
-89dB -32 -57 1
-90dB -oo -oo 0 */
if (db < VOLUME_MIN) {
if (db <= -900) {
return 0;
} else {
return (db-VOLUME_MIN)/10 + 1;
return db / 10 - -90;
}
}
@ -137,6 +137,10 @@ void audiohw_postinit(void)
void audiohw_set_volume(int vol_l, int vol_r)
{
int dac_l, amp_l, dac_r, amp_r;
vol_l = vol_tenthdb2hw(vol_l);
vol_r = vol_tenthdb2hw(vol_r);
get_volume_params(vol_l, &dac_l, &amp_l);
get_volume_params(vol_r, &dac_r, &amp_r);

View File

@ -79,7 +79,7 @@ static int vol_tenthdb2hw(int db)
/* 0110000 == -73dB (0x30 */
/* 0101111..0000000 == mute (0x2f) */
if (db < VOLUME_MIN) {
if (db <= -740) {
return 0x0;
} else {
return((db/10)+73+0x30);

View File

@ -155,20 +155,17 @@ static void wmc_write_masked(unsigned int reg, unsigned int bits,
* (000000...111111) */
static int vol_tenthdb2hw(int db)
{
/* -90dB to +6dB 1dB steps (96 levels) 7bits */
/* 1100000 == +6dB (0x60,96) */
/* 1101010 == 0dB (0x5a,90) */
/* 1000001 == -57dB (0x21,33,DAC) */
/* 0000001 == -89dB (0x01,01) */
/* 0000000 == -90dB (0x00,00,Mute) */
if (db < VOLUME_MIN)
{
/* att DAC AMP result
+6dB 0 +6 96
0dB 0 0 90
-57dB 0 -57 33
-58dB -1 -57 32
-89dB -32 -57 1
-90dB -oo -oo 0 */
if (db <= -900)
return 0x0;
}
else
{
return (db - VOLUME_MIN) / 10;
}
return db / 10 - -90;
}
void audiohw_preinit(void)

View File

@ -104,10 +104,10 @@ static int vol_tenthdb2hw(int db)
-89dB -32 -57 1
-90dB -oo -oo 0 */
if (db < VOLUME_MIN) {
if (db <= -900) {
return 0;
} else {
return (db-VOLUME_MIN)/10 + 1;
return db / 10 - -90;
}
}

View File

@ -22,9 +22,6 @@
#ifndef _AIC3X_H_
#define _AIC3X_H_
#define VOLUME_MIN -630
#define VOLUME_MAX 0
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -64, 0, -25)
/*** definitions ***/

View File

@ -23,9 +23,6 @@
#define _AK4537_H
/* Volume goes from -127.0 ... 0 dB in 0.5 dB increments */
#define VOLUME_MIN -1270
#define VOLUME_MAX 0
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -128, 0, -25)
#define AKC_NUM_REGS 0x11

View File

@ -32,14 +32,8 @@
/*different volume ranges for different AMS chips*/
#if CONFIG_CPU == AS3525v2
/* Headphone volume goes from -81.0 ... +6dB */
#define VOLUME_MIN -810
#define VOLUME_MAX 60
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -82, 6, -25)
#else /* AS3525v1 */
/* Headphone volume goes from -73.5 ... +6dB */
#define VOLUME_MIN -735
#define VOLUME_MAX 60
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25)
#endif /* CONFIG_CPU == AS3525v2 */

View File

@ -126,22 +126,6 @@ AUDIOHW_SETTING(BALANCE, "%", 0, 1, -100, 100, 0)
AUDIOHW_SETTING(CHANNELS, "", 0, 1, 0, 5, 0)
AUDIOHW_SETTING(STEREO_WIDTH, "%", 0, 5, 0, 250, 100)
#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
#ifndef AUDIOHW_NUM_TONE_CONTROLS
#define AUDIOHW_NUM_TONE_CONTROLS 0
#endif
/* volume/balance/treble/bass interdependency main part */
#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
/* convert caps into defines */
#ifdef AUDIOHW_CAPS
/* Tone controls */
@ -183,7 +167,7 @@ AUDIOHW_SETTING(STEREO_WIDTH, "%", 0, 5, 0, 250, 100)
enum
{
/* Band 1 is implied; bands must be contiguous, 1 to N */
AUDIOHW_EQ_BAND1 = 0,
AUDIOHW_EQ_BAND1,
#define AUDIOHW_HAVE_EQ_BAND1
#if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 1))
AUDIOHW_EQ_BAND2,
@ -209,7 +193,6 @@ enum
#define AUDIOHW_HAVE_EQ_FREQUENCY
enum
{
__AUDIOHW_EQ_BAND_FREQUENCY = -1,
#if defined(AUDIOHW_HAVE_EQ_BAND1) && \
(AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 0))
AUDIOHW_EQ_BAND1_FREQUENCY,
@ -235,7 +218,7 @@ enum
AUDIOHW_EQ_BAND5_FREQUENCY,
#define AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
#endif
AUDIOHW_EQ_FREQUENCY_NUM,
AUDIOHW_EQ_FREQUENCY_NUM, /* Keep last */
};
#endif /* AUDIOHW_EQ_FREQUENCY_CAPS */
@ -244,7 +227,6 @@ enum
#define AUDIOHW_HAVE_EQ_WIDTH
enum
{
__AUDIOHW_EQ_BAND_WIDTH = -1,
#if defined(AUDIOHW_HAVE_EQ_BAND1) && \
(AUDIOHW_EQ_WIDTH_CAPS & (EQ_CAP << 1))
AUDIOHW_EQ_BAND2_WIDTH,
@ -267,7 +249,7 @@ enum
/* Types and number of settings types (gain, frequency, width) */
enum AUDIOHW_EQ_SETTINGS
{
AUDIOHW_EQ_GAIN = 0,
AUDIOHW_EQ_GAIN,
#ifdef AUDIOHW_HAVE_EQ_FREQUENCY
AUDIOHW_EQ_FREQUENCY,
#endif
@ -309,104 +291,8 @@ enum AUDIOHW_EQ_SETTINGS
#endif
#endif /* AUDIOHW_CAPS */
enum {
/* TODO: Volume shouldn't be needed if device doesn't have digital control */
SOUND_VOLUME = 0,
/* Tone control */
#if defined(AUDIOHW_HAVE_BASS)
SOUND_BASS,
#endif
#if defined(AUDIOHW_HAVE_TREBLE)
SOUND_TREBLE,
#endif
SOUND_BALANCE,
SOUND_CHANNELS,
SOUND_STEREO_WIDTH,
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
SOUND_LOUDNESS,
SOUND_AVC,
SOUND_MDB_STRENGTH,
SOUND_MDB_HARMONICS,
SOUND_MDB_CENTER,
SOUND_MDB_SHAPE,
SOUND_MDB_ENABLE,
SOUND_SUPERBASS,
#endif
#if defined(AUDIOHW_HAVE_LIN_GAIN)
SOUND_LEFT_GAIN,
SOUND_RIGHT_GAIN,
#endif
#if defined(AUDIOHW_HAVE_MIC_GAIN)
SOUND_MIC_GAIN,
#endif
/* Bass and treble tone controls */
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
SOUND_BASS_CUTOFF,
#endif
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
SOUND_TREBLE_CUTOFF,
#endif
/* 3D effect */
#if defined(AUDIOHW_HAVE_DEPTH_3D)
SOUND_DEPTH_3D,
#endif
/* Hardware EQ tone controls */
/* Band gains */
#if defined(AUDIOHW_HAVE_EQ)
/* Band 1 implied */
SOUND_EQ_BAND1_GAIN,
#if defined(AUDIOHW_HAVE_EQ_BAND2)
SOUND_EQ_BAND2_GAIN,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND3)
SOUND_EQ_BAND3_GAIN,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND4)
SOUND_EQ_BAND4_GAIN,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND5)
SOUND_EQ_BAND5_GAIN,
#endif
/* Band frequencies */
#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
SOUND_EQ_BAND1_FREQUENCY,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
SOUND_EQ_BAND2_FREQUENCY,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
SOUND_EQ_BAND3_FREQUENCY,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
SOUND_EQ_BAND4_FREQUENCY,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
SOUND_EQ_BAND5_FREQUENCY,
#endif
/* Band widths */
#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
SOUND_EQ_BAND2_WIDTH,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
SOUND_EQ_BAND3_WIDTH,
#endif
#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
SOUND_EQ_BAND4_WIDTH,
#endif
#endif /* AUDIOHW_HAVE_EQ */
SOUND_LAST_SETTING, /* Keep this last */
};
enum Channel
{
SOUND_CHAN_STEREO,
SOUND_CHAN_MONO,
SOUND_CHAN_CUSTOM,
SOUND_CHAN_MONO_LEFT,
SOUND_CHAN_MONO_RIGHT,
SOUND_CHAN_KARAOKE,
SOUND_CHAN_NUM_MODES,
};
/* Generate enumeration of SOUND_xxx constants */
#include "audiohw_settings.h"
/* All usable functions implemented by a audio codec drivers. Most of
* the function in sound settings are only called, when in audio codecs
@ -619,8 +505,19 @@ void audiohw_set_monitor(bool enable);
/**
* Set channel configuration.
* @param val new channel value (see enum Channel).
* @param val new channel value (see enum below).
*/
enum AUDIOHW_CHANNEL_CONFIG
{
SOUND_CHAN_STEREO,
SOUND_CHAN_MONO,
SOUND_CHAN_CUSTOM,
SOUND_CHAN_MONO_LEFT,
SOUND_CHAN_MONO_RIGHT,
SOUND_CHAN_KARAOKE,
SOUND_CHAN_NUM_MODES,
};
void audiohw_set_channel(int val);
#ifdef HAVE_PITCHCONTROL

View File

@ -21,6 +21,7 @@
*
****************************************************************************/
#if defined(AUDIOHW_SOUND_SETTINGS_ENTRIES)
#undef AUDIOHW_SOUND_SETTINGS_ENTRIES
/* Define sound_setting_entries table */
#define AUDIOHW_SETTINGS(...) \
@ -38,6 +39,7 @@
[SOUND_##name] = { .info = &_audiohw_setting_##name, .function = fn },
#elif defined(AUDIOHW_SOUND_SETTINGS_VAL2PHYS)
#undef AUDIOHW_SOUND_SETTINGS_VAL2PHYS
/* Implements sound_val2phys */
#define AUDIOHW_SETTINGS(...) \
@ -54,6 +56,19 @@
#define AUDIOHW_SETTING_ENT(name, fn) \
case SOUND_##name: return _sound_val2phys_##name(value);
#else
/* Generate enumeration of SOUND_xxx constants */
#define AUDIOHW_SETTINGS(...) \
enum \
{ \
__VA_ARGS__ \
SOUND_LAST_SETTING, \
};
#define AUDIOHW_SETTING_ENT(name, fn) \
SOUND_##name,
#endif /* setting table type selection */
AUDIOHW_SETTINGS(
@ -139,5 +154,3 @@ AUDIOHW_SETTINGS(
#undef AUDIOHW_SETTINGS
#undef AUDIOHW_SETTING_ENT
#undef AUDIOHW_SOUND_SETTINGS_ENTRIES
#undef AUDIOHW_SOUND_SETTINGS_VAL2PHYS

View File

@ -22,10 +22,6 @@
#ifndef __CS42L55_H__
#define __CS42L55_H__
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -580
#define VOLUME_MAX 120
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | BASS_CUTOFF_CAP | \
TREBLE_CUTOFF_CAP | PRESCALER_CAP | LINEOUT_CAP)

View File

@ -22,9 +22,8 @@
#ifndef __DUMMY_CODEC_H_
#define __DUMMY_CODEC_H_
#define VOLUME_MIN -730
#define VOLUME_MAX 0
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, VOLUME_MIN/10, VOLUME_MAX/10, 0)
#define DUMMY_VOLUME_MIN -740
#define DUMMY_VOLUME_MAX 0
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 0, 0)
#endif /* __DUMMY_CODEC_H_ */

View File

@ -21,11 +21,8 @@
#ifndef HOSTED_CODEC_H
#define HOSTED_CODEC_H
#define VOLUME_MIN -990
#define VOLUME_MAX 0
#define AUDIOHW_CAPS (MONO_VOL_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1,-100, 0, 0)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -99, 0, 0)
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
/* Bass and treble tone controls */

View File

@ -24,9 +24,6 @@
/* i.MX233 can boost up to 6dB in DAC mode and 12dB in line mode. Since mic/line
* already have adjustable gain, keep lowest of both. With chained DAC volume
* and headphone volume, the i.MX233 can achieve < -100dB but stay at -100dB. */
#define VOLUME_MIN -1000
#define VOLUME_MAX 60
#define AUDIOHW_CAPS (DEPTH_3D_CAP | BASS_CAP | TREBLE_CAP | \
LIN_GAIN_CAP | MIC_GAIN_CAP)

View File

@ -21,10 +21,6 @@
#ifndef __JZ4740_CODEC_H_
#define __JZ4740_CODEC_H_
#define VOLUME_MIN -730
#define VOLUME_MAX 60
/* TODO */
#ifdef HAVE_SW_VOLUME_CONTROL
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25)
#else

View File

@ -39,8 +39,6 @@
#if CONFIG_CODEC == MAS3507D
#define VOLUME_MIN -780
#define VOLUME_MAX 180
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | PRESCALER_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -78, 18, -18)
@ -171,9 +169,6 @@ static const unsigned int prescale_table[] =
#else /* CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F */
#define VOLUME_MIN -400
#define VOLUME_MAX 600
AUDIOHW_SETTING(VOLUME, "dB", 0, 1,-100, 12, -25)
AUDIOHW_SETTING(BASS, "dB", 0, 1, -12, 12, 6)
AUDIOHW_SETTING(TREBLE, "dB", 0, 1, -12, 12, 6)

View File

@ -24,8 +24,6 @@
#ifndef _RK27XX_CODEC_H_
#define _RK27XX_CODEC_H_
#define VOLUME_MIN -330
#define VOLUME_MAX 40
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | LIN_GAIN_CAP | MIC_GAIN_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -34, 4, -25)

View File

@ -22,9 +22,6 @@
#ifndef _TLV320_H_
#define _TLV320_H_
#define VOLUME_MIN -730
#define VOLUME_MAX 60
#define AUDIOHW_CAPS (LIN_GAIN_CAP | MIC_GAIN_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -20)

View File

@ -21,10 +21,6 @@
#ifndef __TSC2100_H_
#define __TSC2100_H_
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -630
#define VOLUME_MAX 0
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -64, 0, -25)
void tsc2100_read_data(void);
@ -94,8 +90,6 @@ void tsc2100_keyclick(void);
/* ts codec dac gain control */
#define TSDACGAIN_PAGE 2
#define TSDACGAIN_ADDRESS 0x02
#define VOLUME_MAX 0
#define VOLUME_MIN -630
/* ts audio control 2 */
#define TSAC2_PAGE 2

View File

@ -22,14 +22,10 @@
#ifndef _UDA1341_H
#define _UDA1341_H
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -840
#define VOLUME_MAX 0
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | MIC_GAIN_CAP | LIN_GAIN_CAP\
| MONO_VOL_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -84, 0, -25)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -61, 0, -25)
AUDIOHW_SETTING(BASS, "dB", 0, 2, 0, 24, 0)
AUDIOHW_SETTING(TREBLE, "dB", 0, 2, 0, 6, 0)
#ifdef HAVE_RECORDING

View File

@ -22,14 +22,10 @@
#ifndef _UDA1380_H
#define _UDA1380_H
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -840
#define VOLUME_MAX 0
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | PRESCALER_CAP | \
LIN_GAIN_CAP | MIC_GAIN_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -85, 0, -25)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -84, 0, -25)
AUDIOHW_SETTING(BASS, "dB", 0, 2, 0, 24, 0)
AUDIOHW_SETTING(TREBLE, "dB", 0, 2, 0, 6, 0)
#ifdef HAVE_RECORDING

View File

@ -24,10 +24,6 @@
#ifndef _WM8731_H
#define _WM8731_H
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -730
#define VOLUME_MAX 60
#define AUDIOHW_CAPS (LIN_GAIN_CAP | MIC_GAIN_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25)

View File

@ -21,10 +21,6 @@
#ifndef _WM8751_H
#define _WM8751_H
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -730
#define VOLUME_MAX 60
#if defined(HAVE_WM8750)
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | PRESCALER_CAP | \
BASS_CUTOFF_CAP | TREBLE_CUTOFF_CAP | \

View File

@ -22,10 +22,6 @@
#ifndef _WM8758_H
#define _WM8758_H
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -890
#define VOLUME_MAX 60
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | BASS_CUTOFF_CAP | \
TREBLE_CUTOFF_CAP | LINEOUT_CAP | LIN_GAIN_CAP | \
MIC_GAIN_CAP)

View File

@ -22,10 +22,6 @@
#ifndef _WM8975_H
#define _WM8975_H
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -730
#define VOLUME_MAX 60
#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | LINEOUT_CAP | \
LIN_GAIN_CAP | MIC_GAIN_CAP)

View File

@ -23,9 +23,6 @@
#ifndef _WM8978_H
#define _WM8978_H
#define VOLUME_MIN -890
#define VOLUME_MAX 60
#if 0
#define AUDIOHW_CAPS (EQ_CAP | PRESCALER_CAP | DEPTH_3D_CAP | \
LIN_GAIN_CAP | MIC_GAIN_CAP)

View File

@ -22,10 +22,6 @@
#ifndef _WM8985_H
#define _WM8985_H
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -890
#define VOLUME_MAX 60
#ifdef COWON_D2
/* FIXME: somehow something was out of sync in the .lang, settings and caps. Keep the
* cutoffs disabled until someone with the device works it out. */

View File

@ -112,18 +112,6 @@ void sound_set(int setting, int value)
* by 12 dB after processing.
*/
static int current_volume = 0; /* tenth dB */
static int current_balance = 0; /* percent */
#ifdef AUDIOHW_HAVE_TREBLE
static int current_treble = 0; /* tenth dB */
#endif
#ifdef AUDIOHW_HAVE_BASS
static int current_bass = 0; /* tenth dB */
#endif
#ifdef AUDIOHW_HAVE_EQ
static int current_eq_band_gain[AUDIOHW_EQ_BAND_NUM]; /* tenth dB */
#endif
/* Return the sound value scaled to centibels (tenth-decibels) */
static int sound_value_to_cb(int setting, int value)
{
@ -133,20 +121,44 @@ static int sound_value_to_cb(int setting, int value)
return value;
}
static struct
{
int volume; /* tenth dB */
int balance; /* percent */
#if defined(AUDIOHW_HAVE_BASS)
int bass; /* tenth dB */
#endif
#if defined(AUDIOHW_HAVE_TREBLE)
int treble; /* tenth dB */
#endif
#if defined(AUDIOHW_HAVE_EQ)
int eq_gain[AUDIOHW_EQ_BAND_NUM]; /* tenth dB */
#endif
} sound_prescaler;
#if defined(AUDIOHW_HAVE_BASS) || defined (AUDIOHW_HAVE_TREBLE) \
|| defined(AUDIOHW_HAVE_EQ)
#define TONE_PRESCALER
#endif
static void set_prescaled_volume(void)
{
int prescale = 0;
#if defined(TONE_PRESCALER) || !defined(AUDIOHW_HAVE_MONO_VOLUME)
const int minvol = sound_value_to_cb(SOUND_VOLUME, sound_min(SOUND_VOLUME));
#endif
int volume = sound_prescaler.volume;
#if defined(AUDIOHW_HAVE_BASS) || defined(AUDIOHW_HAVE_TREBLE) \
|| defined(AUDIOHW_HAVE_EQ)
#if defined(TONE_PRESCALER)
int prescale = 0;
/* Note: Having Tone + EQ isn't prohibited */
#if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
prescale = MAX(current_bass, current_treble);
prescale = MAX(sound_prescaler.bass, sound_prescaler.treble);
#endif
#if defined(AUDIOHW_HAVE_EQ)
for (int i = 0; i < AUDIOHW_EQ_BAND_NUM; i++)
prescale = MAX(current_eq_band_gain[i], prescale);
prescale = MAX(sound_prescaler.eq_gain[i], prescale);
#endif
if (prescale < 0)
@ -156,31 +168,38 @@ static void set_prescaled_volume(void)
/* Gain up the analog volume to compensate the prescale gain reduction,
* but if this would push the volume over the top, reduce prescaling
* instead (might cause clipping). */
if (current_volume + prescale > VOLUME_MAX)
prescale = VOLUME_MAX - current_volume;
const int maxvol = sound_value_to_cb(SOUND_VOLUME, sound_max(SOUND_VOLUME));
if (volume + prescale > maxvol)
prescale = maxvol - volume;
audiohw_set_prescaler(prescale);
if (current_volume < VOLUME_MIN)
if (volume <= minvol)
prescale = 0; /* Make sure the audio gets muted */
#endif /* AUDIOHW_HAVE_BASS || AUDIOHW_HAVE_TREBLE || AUDIOHW_HAVE_EQ */
#ifndef AUDIOHW_HAVE_MONO_VOLUME
/* At the moment, such targets have lousy volume resolution and so minute
boost won't work how we'd like */
volume += prescale;
#endif
#endif /* TONE_PRESCALER */
#if defined(AUDIOHW_HAVE_MONO_VOLUME)
audiohw_set_volume(current_volume);
audiohw_set_volume(volume);
#else /* Stereo volume */
int l = current_volume + prescale, r = l;
int l = volume, r = volume;
/* Balance the channels scaled by the current volume and min volume. */
/* Subtract a dB from VOLUME_MIN to get it to a mute level */
int volshift = current_balance * VOLUME_RANGE / 100; /* tenth of dB */
/* Balance the channels scaled by the current volume and min volume */
int balance = sound_prescaler.balance; /* percent */
if (volshift > 0)
if (balance > 0)
{
l -= ((l - (VOLUME_MIN - ONE_DB)) * volshift) / VOLUME_RANGE;
l -= (l - minvol) * balance / 100;
}
else if (volshift < 0)
else if (balance < 0)
{
r += ((r - (VOLUME_MIN - ONE_DB)) * volshift) / VOLUME_RANGE;
r += (r - minvol) * balance / 100;
}
audiohw_set_volume(l, r);
@ -190,8 +209,6 @@ static void set_prescaled_volume(void)
/* For now, lineout stays at unity */
audiohw_set_lineout_volume(0, 0);
#endif /* AUDIOHW_HAVE_LINEOUT */
(void)prescale; /* In case of no tone controls + mono volume */
}
#endif /* AUDIOIHW_HAVE_CLIPPING */
@ -203,7 +220,7 @@ void sound_set_volume(int value)
#if defined(AUDIOHW_HAVE_CLIPPING)
audiohw_set_volume(value);
#else
current_volume = sound_value_to_cb(SOUND_VOLUME, value);
sound_prescaler.volume = sound_value_to_cb(SOUND_VOLUME, value);
set_prescaled_volume();
#endif
}
@ -216,12 +233,12 @@ void sound_set_balance(int value)
#if defined(AUDIOHW_HAVE_BALANCE)
audiohw_set_balance(value);
#else
current_balance = value;
sound_prescaler.balance = value;
set_prescaled_volume();
#endif
}
#ifdef AUDIOHW_HAVE_BASS
#if defined(AUDIOHW_HAVE_BASS)
void sound_set_bass(int value)
{
if (!audio_is_initialized)
@ -230,13 +247,13 @@ void sound_set_bass(int value)
audiohw_set_bass(value);
#if !defined(AUDIOHW_HAVE_CLIPPING)
current_bass = sound_value_to_cb(SOUND_BASS, value);
sound_prescaler.bass = sound_value_to_cb(SOUND_BASS, value);
set_prescaled_volume();
#endif
}
#endif /* AUDIOHW_HAVE_BASS */
#ifdef AUDIOHW_HAVE_TREBLE
#if defined(AUDIOHW_HAVE_TREBLE)
void sound_set_treble(int value)
{
if (!audio_is_initialized)
@ -245,7 +262,7 @@ void sound_set_treble(int value)
audiohw_set_treble(value);
#if !defined(AUDIOHW_HAVE_CLIPPING)
current_treble = sound_value_to_cb(SOUND_TREBLE, value);
sound_prescaler.treble = sound_value_to_cb(SOUND_TREBLE, value);
set_prescaled_volume();
#endif
}
@ -259,7 +276,7 @@ void sound_set_bass_cutoff(int value)
audiohw_set_bass_cutoff(value);
}
#endif
#endif /* AUDIOHW_HAVE_BASS_CUTOFF */
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
void sound_set_treble_cutoff(int value)
@ -269,7 +286,7 @@ void sound_set_treble_cutoff(int value)
audiohw_set_treble_cutoff(value);
}
#endif
#endif /* AUDIOHW_HAVE_TREBLE_CUTOFF */
void sound_set_channels(int value)
{
@ -295,7 +312,7 @@ void sound_set_depth_3d(int value)
audiohw_set_depth_3d(value);
}
#endif
#endif /* AUDIOHW_HAVE_DEPTH_3D */
#if defined(AUDIOHW_HAVE_EQ)
int sound_enum_hw_eq_band_setting(unsigned int band,
@ -370,11 +387,13 @@ static void sound_set_hw_eq_band_gain(unsigned int band, int value)
if (!audio_is_initialized)
return;
int setting = sound_enum_hw_eq_band_setting(band, AUDIOHW_EQ_GAIN);
current_eq_band_gain[band] = sound_value_to_cb(setting, value);
audiohw_set_eq_band_gain(band, value);
#if !defined (AUDIOHW_HAVE_CLIPPING)
int setting = sound_enum_hw_eq_band_setting(band, AUDIOHW_EQ_GAIN);
sound_prescaler.eq_gain[band] = sound_value_to_cb(setting, value);
set_prescaled_volume();
#endif /* AUDIOHW_HAVE_CLIPPING */
}
void sound_set_hw_eq_band1_gain(int value)
@ -557,7 +576,7 @@ void sound_set_superbass(int value)
}
#endif /* CONFIG_CODEC == MAS3587F || CONFIG_CODEC == MAS3539F */
#ifdef HAVE_PITCHCONTROL
#if defined(HAVE_PITCHCONTROL)
void sound_set_pitch(int32_t pitch)
{
if (!audio_is_initialized)

View File

@ -427,9 +427,9 @@ void pcm_play_dma_postinit(void)
void pcm_set_mixer_volume(int volume)
{
/* gstreamer volume range is from 0.00 to 1.00 */
gdouble gst_vol = (gdouble)(volume - VOLUME_MIN) / (gdouble)VOLUME_RANGE;
/* gstreamer volume range is from 0.00 to 1.00
* input is -990..0 */
gdouble gst_vol = 1.0f - (gdouble)volume / -990.0f;
g_object_set (G_OBJECT(gst_volume), "volume", gst_vol, NULL);
}

View File

@ -421,7 +421,9 @@ void pcm_play_dma_postinit(void)
#ifndef HAVE_SW_VOLUME_CONTROL
void pcm_set_mixer_volume(int volume)
{
sim_volume = volume;
int minvol = sound_min(SOUND_VOLUME);
int volrange = sound_max(SOUND_VOLUME) - minvol;
sim_volume = SDL_MIX_MAXVOLUME * (volume / 10 - minvol) / volrange;
}
#endif /* HAVE_SW_VOLUME_CONTROL */

View File

@ -273,9 +273,9 @@ void audiohw_init(void)
void audiohw_set_volume(int vol_l, int vol_r)
{
#ifdef HAVE_SW_VOLUME_CONTROL
/* SW volume for <= 1.0 gain, HW at unity, < VOLUME_MIN == MUTE */
int sw_volume_l = vol_l < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_l, 0);
int sw_volume_r = vol_r < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_r, 0);
/* SW volume for <= 1.0 gain, HW at unity, < -740 == MUTE */
int sw_volume_l = vol_l <= -740 ? PCM_MUTE_LEVEL : MIN(vol_l, 0);
int sw_volume_r = vol_r <= -740 ? PCM_MUTE_LEVEL : MIN(vol_r, 0);
pcm_set_master_volume(sw_volume_l, sw_volume_r);
#endif /* HAVE_SW_VOLUME_CONTROL */