summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-12-07 23:07:07 +0000
committerJens Arnold <amiconn@rockbox.org>2005-12-07 23:07:07 +0000
commit2993ae69b5cfd95ddab595fcce9cc7637477d6a5 (patch)
tree1a9ba25c51db3d7313621da6dcf5bb4192cfea9d
parentec32c08a357bde454c11a41375230461509f2fe2 (diff)
downloadrockbox-2993ae69b5cfd95ddab595fcce9cc7637477d6a5.zip
rockbox-2993ae69b5cfd95ddab595fcce9cc7637477d6a5.tar.gz
rockbox-2993ae69b5cfd95ddab595fcce9cc7637477d6a5.tar.bz2
rockbox-2993ae69b5cfd95ddab595fcce9cc7637477d6a5.tar.xz
Simplified and uniform volume handling: * Volume setting in dB on all targets, within the 'natural' range defined by the respective DAC (limited to -100..+12 dB for archos Recorders and Ondios in order to avoid 4 chars being displayed in the status bar). 0 dB means line level on all targets. * No more artificial volume limiting for Iriver and Player, settings always represent true values. Removed the various sound scaling options. * Bumped config version so save your settings. Also make sure to adjust the volume after loading a .cfg, then save the .cfg again, otherwise the volume will be out of range (a flaw in the .cfg loader).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8197 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/gwps-common.c7
-rw-r--r--apps/gui/statusbar.c39
-rw-r--r--apps/gui/statusbar.h2
-rw-r--r--apps/lang/english.lang30
-rw-r--r--apps/settings.c17
-rw-r--r--apps/settings.h3
-rw-r--r--apps/sound_menu.c18
-rw-r--r--firmware/export/sound.h15
-rw-r--r--firmware/sound.c216
9 files changed, 87 insertions, 260 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 7590f49..307036e 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -569,7 +569,10 @@ static char* get_tag(struct wps_data* wps_data,
case 'v': /* volume */
*flags |= WPS_REFRESH_DYNAMIC;
snprintf(buf, buf_size, "%d", global_settings.volume);
- *intval = global_settings.volume / 10 + 1;
+ *intval = 10 * (global_settings.volume
+ - sound_min(SOUND_VOLUME))
+ / (sound_max(SOUND_VOLUME)
+ - sound_min(SOUND_VOLUME)) + 1;
return buf;
}
@@ -1892,7 +1895,7 @@ bool update_onvol_change(struct gui_wps * gwps)
gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC);
#ifdef HAVE_LCD_CHARCELLS
- gui_splash(gwps->display,0, false, "Vol: %d %% ",
+ gui_splash(gwps->display,0, false, "Vol: %d dB ",
sound_val2phys(SOUND_VOLUME, global_settings.volume));
return true;
#endif
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index fda54a6..56d1647 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -102,7 +102,7 @@ struct gui_syncstatusbar statusbars;
void gui_statusbar_init(struct gui_statusbar * bar)
{
- bar->last_volume = -1; /* -1 means "first update ever" */
+ bar->last_volume = -1000; /* -1000 means "first update ever" */
bar->battery_icon_switch_tick = 0;
#ifdef HAVE_CHARGING
bar->battery_charge_step = 0;
@@ -117,6 +117,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
#endif /* CONFIG_RTC */
#ifdef HAVE_LCD_CHARCELLS
+ int vol;
(void)force_redraw; /* players always "redraw" */
#endif /* HAVE_LCD_CHARCELLS */
@@ -277,12 +278,14 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
display->icon(ICON_BATTERY_2, bar->info.battlevel > 50);
display->icon(ICON_BATTERY_3, bar->info.battlevel > 75);
+ vol = 100 * (bar->info.volume - sound_min(SOUND_VOLUME))
+ / (sound_max(SOUND_VOLUME) - sound_min(SOUND_VOLUME));
display->icon(ICON_VOLUME, true);
- display->icon(ICON_VOLUME_1, bar->info.volume > 10);
- display->icon(ICON_VOLUME_2, bar->info.volume > 30);
- display->icon(ICON_VOLUME_3, bar->info.volume > 50);
- display->icon(ICON_VOLUME_4, bar->info.volume > 70);
- display->icon(ICON_VOLUME_5, bar->info.volume > 90);
+ display->icon(ICON_VOLUME_1, vol > 10);
+ display->icon(ICON_VOLUME_2, vol > 30);
+ display->icon(ICON_VOLUME_3, vol > 50);
+ display->icon(ICON_VOLUME_4, vol > 70);
+ display->icon(ICON_VOLUME_5, vol > 90);
display->icon(ICON_PLAY, current_playmode() == STATUS_PLAY);
display->icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE);
@@ -356,31 +359,31 @@ void gui_statusbar_icon_battery(struct screen * display, int percent)
/*
* Print volume gauge to status bar
*/
-bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent)
+bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume)
{
int i;
- int volume;
int vol;
char buffer[4];
unsigned int width, height;
bool needs_redraw = false;
int type = global_settings.volume_type;
- struct screen * display=bar->display;
+ struct screen * display=bar->display;
+ int minvol = sound_min(SOUND_VOLUME);
+ int maxvol = sound_max(SOUND_VOLUME);
- volume = percent;
- if (volume < 0)
- volume = 0;
- if (volume > 100)
- volume = 100;
+ if (volume < minvol)
+ volume = minvol;
+ if (volume > maxvol)
+ volume = maxvol;
- if (volume == 0) {
+ if (volume == minvol) {
display->mono_bitmap(bitmap_icons_7x8[Icon_Mute],
STATUSBAR_VOLUME_X_POS + STATUSBAR_VOLUME_WIDTH / 2 - 4,
STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT);
}
else {
/* We want to redraw the icon later on */
- if (bar->last_volume != volume && bar->last_volume >= 0) {
+ if (bar->last_volume != volume && bar->last_volume >= minvol) {
bar->volume_icon_switch_tick = current_tick + HZ;
}
@@ -395,7 +398,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent)
if (type)
{
display->setfont(FONT_SYSFIXED);
- snprintf(buffer, sizeof(buffer), "%2d", percent);
+ snprintf(buffer, sizeof(buffer), "%2d", volume);
display->getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT)
{
@@ -406,7 +409,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent)
display->setfont(FONT_UI);
} else {
/* display volume bar */
- vol = volume * 14 / 100;
+ vol = (volume - minvol) * 14 / (maxvol - minvol);
for(i=0; i < vol; i++) {
display->vline(STATUSBAR_VOLUME_X_POS + i,
STATUSBAR_Y_POS + 6 - i / 2,
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h
index 6b8e49a..650b49d 100644
--- a/apps/gui/statusbar.h
+++ b/apps/gui/statusbar.h
@@ -102,7 +102,7 @@ extern void gui_statusbar_init(struct gui_statusbar * bar);
extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw);
void gui_statusbar_icon_battery(struct screen * display, int percent);
-bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent);
+bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume);
void gui_statusbar_icon_play_state(struct screen * display, int state);
void gui_statusbar_icon_play_mode(struct screen * display, int mode);
void gui_statusbar_icon_shuffle(struct screen * display);
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 3595281..1f0ef87 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3550,33 +3550,3 @@ desc: in radio screen / menu
eng: "Mode:"
voice: ""
new:
-
-id: LANG_SCALING_MODE
-desc: in sound_settings. How to scale volume/bass to prevent clipping
-eng: "Prevent clipping"
-voice: "Prevent clipping"
-new:
-
-id: LANG_SCALE_OFF
-desc: in sound_settings. Do not reduce volume/bass
-eng: "Off"
-voice: "Off"
-new:
-
-id: LANG_SCALE_VOLUME
-desc: in sound_settings. Reduce volume
-eng: "Adjust volume"
-voice: "Adjust volume"
-new:
-
-id: LANG_SCALE_BASS
-desc: in sound_settings. Reduce bass
-eng: "Adjust bass"
-voice: "Adjust bass"
-new:
-
-id: LANG_SCALE_CURRENT
-desc: in sound_settings. Reduce other metric than currently modified
-eng: "Adjust current"
-voice: "Adjust current"
-new:
diff --git a/apps/settings.c b/apps/settings.c
index d344163..bd6076d 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -85,7 +85,7 @@ const char rec_base_directory[] = REC_BASE_DIR;
#include "dsp.h"
#endif
-#define CONFIG_BLOCK_VERSION 35
+#define CONFIG_BLOCK_VERSION 36
#define CONFIG_BLOCK_SIZE 512
#define RTC_BLOCK_SIZE 44
@@ -193,7 +193,11 @@ static const struct bit_entry rtc_bits[] =
/* # of bits, offset+size, default, .cfg name, .cfg values */
/* sound */
- {7, S_O(volume), 70, "volume", NULL }, /* 0...100 */
+#if CONFIG_CODEC == MAS3507D
+ {8 | SIGNED, S_O(volume), -18, "volume", NULL }, /* -78...+18 */
+#else
+ {8 | SIGNED, S_O(volume), -25, "volume", NULL }, /* -100...+12 / -84...0 */
+#endif
{8 | SIGNED, S_O(balance), 0, "balance", NULL }, /* -100...100 */
#if CONFIG_CODEC != SWCODEC /* any MAS */
{5 | SIGNED, S_O(bass), 0, "bass", NULL }, /* -15..+15 / -12..+12 */
@@ -210,9 +214,6 @@ static const struct bit_entry rtc_bits[] =
{3, S_O(channel_config), 0, "channels",
"stereo,mono,custom,mono left,mono right,karaoke" },
{8, S_O(stereo_width), 100, "stereo width", NULL},
-#ifdef HAVE_UDA1380
- {2, S_O(sound_scaling), SOUND_SCALE_VOLUME, "prevent clipping", "adjust volume,adjust bass,adjust current,off"},
-#endif
/* playback */
{1, S_O(resume), false, "resume", off_on },
{1, S_O(playlist_shuffle), false, "shuffle", off_on },
@@ -842,9 +843,6 @@ void sound_settings_apply(void)
sound_set(SOUND_VOLUME, global_settings.volume);
sound_set(SOUND_CHANNELS, global_settings.channel_config);
sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width);
-#ifdef HAVE_UDA1380
- sound_set(SOUND_SCALING, global_settings.sound_scaling);
-#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
sound_set(SOUND_LOUDNESS, global_settings.loudness);
sound_set(SOUND_AVC, global_settings.avc);
@@ -1429,9 +1427,6 @@ void settings_reset(void) {
global_settings.treble = sound_default(SOUND_TREBLE);
global_settings.channel_config = sound_default(SOUND_CHANNELS);
global_settings.stereo_width = sound_default(SOUND_STEREO_WIDTH);
-#ifdef HAVE_UDA1380
- global_settings.sound_scaling = sound_default(SOUND_SCALING);
-#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
global_settings.loudness = sound_default(SOUND_LOUDNESS);
global_settings.avc = sound_default(SOUND_AVC);
diff --git a/apps/settings.h b/apps/settings.h
index 6b34543..b1e8c9e 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -157,9 +157,6 @@ struct user_settings
int avc; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */
int channel_config; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */
int stereo_width; /* 0-255% */
-#ifdef HAVE_UDA1380
- int sound_scaling; /* Off, Volume, Bass, Current metric */
-#endif
int mdb_strength; /* 0-127dB */
int mdb_harmonics; /* 0-100% */
int mdb_center; /* 20-300Hz */
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index f97cdde..e44aa68 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -366,21 +366,6 @@ static bool stereo_width(void)
SOUND_STEREO_WIDTH);
}
-#ifdef HAVE_UDA1380
-static bool sound_scaling(void)
-{
- static const struct opt_items names[] = {
- { STR(LANG_SCALE_VOLUME) },
- { STR(LANG_SCALE_BASS) },
- { STR(LANG_SCALE_CURRENT)},
- { STR(LANG_SCALE_OFF) }
- };
-
- return set_option(str(LANG_SCALING_MODE), &global_settings.sound_scaling, INT,
- names, 4, sound_set_scaling);
-}
-#endif
-
bool sound_menu(void)
{
int m;
@@ -395,9 +380,6 @@ bool sound_menu(void)
#if CONFIG_CODEC == SWCODEC
{ ID2P(LANG_CROSSFEED), crossfeed },
#endif
-#ifdef HAVE_UDA1380
- { ID2P(LANG_SCALING_MODE), sound_scaling },
-#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
{ ID2P(LANG_LOUDNESS), loudness },
{ ID2P(LANG_AUTOVOL), avc },
diff --git a/firmware/export/sound.h b/firmware/export/sound.h
index 3c7dec6..2c00206 100644
--- a/firmware/export/sound.h
+++ b/firmware/export/sound.h
@@ -26,9 +26,6 @@ enum {
SOUND_BALANCE,
SOUND_CHANNELS,
SOUND_STEREO_WIDTH,
-#ifdef HAVE_UDA1380
- SOUND_SCALING,
-#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
SOUND_LOUDNESS,
SOUND_AVC,
@@ -59,15 +56,6 @@ enum {
SOUND_CHAN_KARAOKE,
};
-#ifdef HAVE_UDA1380
-enum {
- SOUND_SCALE_VOLUME = 0,
- SOUND_SCALE_BASS,
- SOUND_SCALE_CURRENT,
- SOUND_SCALE_OFF
-};
-#endif
-
typedef void sound_set_type(int value);
const char *sound_unit(int setting);
@@ -84,9 +72,6 @@ void sound_set_bass(int value);
void sound_set_treble(int value);
void sound_set_channels(int value);
void sound_set_stereo_width(int value);
-#ifdef HAVE_UDA1380
-void sound_set_scaling(int value);
-#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
void sound_set_loudness(int value);
void sound_set_avc(int value);
diff --git a/firmware/sound.c b/firmware/sound.c
index 20c796b..555280c 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -56,15 +56,16 @@ struct sound_settings_info {
};
static const struct sound_settings_info sound_settings_table[] = {
- [SOUND_VOLUME] = {"%", 0, 1, 0, 100, 70, sound_set_volume},
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+ [SOUND_VOLUME] = {"dB", 0, 1,-100, 12, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -12, 12, 6, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 6, sound_set_treble},
#elif defined(HAVE_UDA1380)
+ [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 2, 0, 24, 0, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0, sound_set_treble},
- [SOUND_SCALING] = {"", 0, 1, 0, 1, SOUND_SCALE_VOLUME, sound_set_scaling},
#else /* MAS3507D */
+ [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -15, 15, 7, sound_set_treble},
#endif
@@ -228,11 +229,12 @@ static const unsigned int prescale_table[] =
0xe9400 /* 15dB */
};
-/* convert tenth of dB volume to dac3550 register value */
-static int tenthdb2reg(int db) {
- if (db < -540)
+/* convert tenth of dB volume (-780..+180) to dac3550 register value */
+static int tenthdb2reg(int db)
+{
+ if (db < -540) /* 3 dB steps */
return (db + 780) / 30;
- else
+ else /* 1.5 dB steps */
return (db + 660) / 15;
}
#endif
@@ -241,8 +243,9 @@ static int tenthdb2reg(int db) {
#define VOLUME_MIN -840
#define VOLUME_MAX 0
-/* convert tenth of dB volume to master volume register value */
-static int tenthdb2master(int db) {
+/* convert tenth of dB volume (-840..0) to master volume register value */
+static int tenthdb2master(int db)
+{
if (db < -720) /* 1.5 dB steps */
return (2940 - db) / 15;
else if (db < -660) /* 0.75 dB steps */
@@ -253,16 +256,16 @@ static int tenthdb2master(int db) {
return -db * 2 / 5;
}
-static int tenthdb2mixer(int db) {
- if (db < -720)
- return 228;
- else if (db < -660)
- return 224;
- else if (db < -600)
- return 216;
- else if (db < -470)
- return (460 - db) / 5;
- else
+/* convert tenth of dB volume (-780..0) to mixer volume register value */
+static int tenthdb2mixer(int db)
+{
+ if (db < -660) /* 1.5 dB steps */
+ return (2640 - db) / 15;
+ else if (db < -600) /* 0.75 dB steps */
+ return (990 - db) * 2 / 15;
+ else if (db < -460) /* 0.5 dB steps */
+ return (460 - db) / 5;
+ else /* 0.25 dB steps */
return -db * 2 / 5;
}
@@ -278,89 +281,6 @@ int current_balance = 0; /* -960..+960 -840..+840 */
int current_treble = 0; /* -150..+150 0.. +60 */
int current_bass = 0; /* -150..+150 0..+240 */
-#ifdef HAVE_UDA1380
-
-#define MODIFYING_VOLUME 0
-#define MODIFYING_BASS 1
-#define MODIFYING_BALANCE 2
-#define MODIFYING_NONE 3
-
-int current_scaling_mode = SOUND_SCALE_VOLUME;
-int current_start_l_r = VOLUME_MAX;
-
-static void set_prescaled_volume_and_bass(int scaling_mode, bool just_balance)
-{
- int l = VOLUME_MAX, r = VOLUME_MAX, prescale;
- int new_bass = 0, new_volume = 0;
-
- if(scaling_mode == SOUND_SCALE_OFF)
- {
- if (current_volume > VOLUME_MAX)
- current_volume = VOLUME_MAX;
- new_bass = (current_bass/10) >> 1;
- new_volume = tenthdb2mixer(current_volume);
-
- }
- else if(scaling_mode == SOUND_SCALE_BASS)
- {
- if (current_volume > VOLUME_MAX)
- current_volume = VOLUME_MAX;
-
- prescale = ((VOLUME_MAX - current_volume) / 20);
-
- if ((current_bass + current_volume) <= VOLUME_MAX)
- new_bass = current_bass / 20;
- else
- new_bass = prescale; /* limit bass with volume */
-
- new_volume = tenthdb2mixer(current_volume);
-
- }
- else if(scaling_mode == SOUND_SCALE_VOLUME)
- {
- prescale = current_bass;
- if (prescale < 0)
- prescale = 0;
-
- new_bass = (current_bass/10) >> 1;
- new_volume = prescale*2/5;
-
- if (current_volume + prescale > VOLUME_MAX)
- prescale = VOLUME_MAX - current_volume;
-
- l = r = current_volume + prescale;
- }
- else if(scaling_mode == SOUND_SCALE_CURRENT)
- {
- l = r = current_start_l_r;
-
- }
-
- if(!just_balance)
- {
- uda1380_set_bass(new_bass);
- uda1380_set_mixer_vol(new_volume, new_volume);
- }
-
- current_start_l_r = l;
-
- if (current_balance > 0) {
- l -= current_balance;
- if (l < VOLUME_MIN)
- l = VOLUME_MIN;
- }
- if (current_balance < 0) {
- r += current_balance;
- if (r < VOLUME_MIN)
- r = VOLUME_MIN;
- }
-
- uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r));
-}
-
-#endif
-
-#if CONFIG_CODEC == MAS3507D
static void set_prescaled_volume(void)
{
int prescale;
@@ -371,12 +291,21 @@ static void set_prescaled_volume(void)
prescale = 0; /* no need to prescale if we don't boost
bass or treble */
- mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
-
- /* gain up the analog volume to compensate the prescale gain reduction,
- * but limit to the possible maximum */
+ /* 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;
+
+#if CONFIG_CODEC == MAS3507D
+ mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
+#else /* UDA1380 */
+ uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
+#endif
+
+ if (current_volume == VOLUME_MIN)
+ prescale = 0; /* Make sure the chip gets muted at VOLUME_MIN */
+
l = r = current_volume + prescale;
if (current_balance > 0)
@@ -392,28 +321,12 @@ static void set_prescaled_volume(void)
r = VOLUME_MIN;
}
+#if CONFIG_CODEC == MAS3507D
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
-}
+#else /* UDA1380 */
+ uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r));
#endif
-
-#ifdef HAVE_UDA1380
-static void set_prescaled_volume(int modifying)
-{
- if (modifying == MODIFYING_BALANCE)
- set_prescaled_volume_and_bass(current_scaling_mode,true);
- else if (current_scaling_mode == SOUND_SCALE_OFF)
- set_prescaled_volume_and_bass(current_scaling_mode,false);
- else if(( (modifying == MODIFYING_BASS)
- && (current_scaling_mode == SOUND_SCALE_CURRENT)) ||
- (current_scaling_mode == SOUND_SCALE_VOLUME))
- set_prescaled_volume_and_bass(SOUND_SCALE_VOLUME,false);
- else if(( (modifying == MODIFYING_VOLUME)
- && (current_scaling_mode == SOUND_SCALE_CURRENT)) ||
- (current_scaling_mode == SOUND_SCALE_BASS))
- set_prescaled_volume_and_bass(SOUND_SCALE_BASS,false);
}
-#endif
-
#endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */
#endif /* !SIMULATOR */
@@ -509,18 +422,15 @@ void sound_set_volume(int value)
if(!audio_is_initialized)
return;
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- int tmp = 0x7f00 * value / 100;
- mas_codec_writereg(0x10, tmp & 0xff00);
-#elif (CONFIG_CODEC == MAS3507D)
- current_volume = VOLUME_MIN + (value * VOLUME_RANGE / 100);
- set_prescaled_volume(); /* tenth of dB */
-#elif defined HAVE_UDA1380
- current_volume = VOLUME_MIN + (value * VOLUME_RANGE / 100);
- set_prescaled_volume(MODIFYING_VOLUME); /* tenth of dB */
+ unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8;
+ mas_codec_writereg(0x10, tmp);
+#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380
+ current_volume = value * 10; /* tenth of dB */
+ set_prescaled_volume();
#elif (CONFIG_CPU == PP5020)
/* TODO: Implement sound_set_volume() */
(void)value;
-#endif
+#endif
}
void sound_set_balance(int value)
@@ -528,18 +438,15 @@ void sound_set_balance(int value)
if(!audio_is_initialized)
return;
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- int tmp = ((value * 127 / 100) & 0xff) << 8;
- mas_codec_writereg(0x11, tmp & 0xff00);
-#elif CONFIG_CODEC == MAS3507D
+ unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8;
+ mas_codec_writereg(0x11, tmp);
+#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380
current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
set_prescaled_volume();
-#elif defined HAVE_UDA1380
- current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
- set_prescaled_volume(MODIFYING_BALANCE);
#elif (CONFIG_CPU == PP5020)
/* TODO: Implement sound_set_balance() */
(void)value;
-#endif
+#endif
}
void sound_set_bass(int value)
@@ -547,15 +454,16 @@ void sound_set_bass(int value)
if(!audio_is_initialized)
return;
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- int tmp = ((value * 8) & 0xff) << 8;
- mas_codec_writereg(0x14, tmp & 0xff00);
+ unsigned tmp = ((unsigned)(value * 8) & 0xff) << 8;
+ mas_codec_writereg(0x14, tmp);
#elif CONFIG_CODEC == MAS3507D
mas_writereg(MAS_REG_KBASS, bass_table[value+15]);
current_bass = value * 10;
set_prescaled_volume();
#elif defined(HAVE_UDA1380)
+ uda1380_set_bass(value >> 1);
current_bass = value * 10;
- set_prescaled_volume(MODIFYING_BASS);
+ set_prescaled_volume();
#elif (CONFIG_CPU == PP5020)
/* TODO: Implement sound_set_bass() */
(void)value;
@@ -567,8 +475,8 @@ void sound_set_treble(int value)
if(!audio_is_initialized)
return;
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- int tmp = ((value * 8) & 0xff) << 8;
- mas_codec_writereg(0x15, tmp & 0xff00);
+ unsigned tmp = ((unsigned)(value * 8) & 0xff) << 8;
+ mas_codec_writereg(0x15, tmp);
#elif CONFIG_CODEC == MAS3507D
mas_writereg(MAS_REG_KTREBLE, treble_table[value+15]);
current_treble = value * 10;
@@ -576,6 +484,7 @@ void sound_set_treble(int value)
#elif defined(HAVE_UDA1380)
uda1380_set_treble(value >> 1);
current_treble = value * 10;
+ set_prescaled_volume();
#elif (CONFIG_CPU == PP5020)
/* TODO: Implement sound_set_treble() */
(void)value;
@@ -599,16 +508,6 @@ void sound_set_stereo_width(int value)
set_channel_config();
}
-#ifdef HAVE_UDA1380
-void sound_set_scaling(int value)
-{
- current_scaling_mode = value;
- if(!audio_is_initialized)
- return;
- set_prescaled_volume(MODIFYING_NONE);
-}
-#endif
-
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
void sound_set_loudness(int value)
{
@@ -726,13 +625,6 @@ void sound_set_stereo_width(int value)
(void)value;
}
-#ifdef HAVE_UDA1380
-void sound_set_scaling(int value)
-{
- (void)value;
-}
-#endif
-
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
void sound_set_loudness(int value)
{