summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-04-20 04:06:13 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-04-22 20:38:17 -0400
commite61e9c61d0ba6990576d59efca07afa13fd97566 (patch)
tree4b17b22dd4f56568666e25292f38224529ec7113 /firmware/drivers
parent91b33d5a3e92d62cf6fb6be875437d35b632caf5 (diff)
downloadrockbox-e61e9c61d0ba6990576d59efca07afa13fd97566.zip
rockbox-e61e9c61d0ba6990576d59efca07afa13fd97566.tar.gz
rockbox-e61e9c61d0ba6990576d59efca07afa13fd97566.tar.bz2
rockbox-e61e9c61d0ba6990576d59efca07afa13fd97566.tar.xz
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
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/audio/aic3x.c6
-rw-r--r--firmware/drivers/audio/ak4537.c4
-rw-r--r--firmware/drivers/audio/as3514.c17
-rw-r--r--firmware/drivers/audio/cs42l55.c2
-rw-r--r--firmware/drivers/audio/dummy_codec.c6
-rw-r--r--firmware/drivers/audio/rk27xx_codec.c2
-rw-r--r--firmware/drivers/audio/sdl.c20
-rw-r--r--firmware/drivers/audio/tlv320.c2
-rw-r--r--firmware/drivers/audio/tsc2100.c6
-rw-r--r--firmware/drivers/audio/uda1341.c2
-rw-r--r--firmware/drivers/audio/wm8731.c2
-rw-r--r--firmware/drivers/audio/wm8751.c2
-rw-r--r--firmware/drivers/audio/wm8758.c10
-rw-r--r--firmware/drivers/audio/wm8975.c2
-rw-r--r--firmware/drivers/audio/wm8978.c21
-rw-r--r--firmware/drivers/audio/wm8985.c4
16 files changed, 57 insertions, 51 deletions
diff --git a/firmware/drivers/audio/aic3x.c b/firmware/drivers/audio/aic3x.c
index 60330f1..9b705db 100644
--- a/firmware/drivers/audio/aic3x.c
+++ b/firmware/drivers/audio/aic3x.c
@@ -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));
}
}
diff --git a/firmware/drivers/audio/ak4537.c b/firmware/drivers/audio/ak4537.c
index 1628af8..90d264e 100644
--- a/firmware/drivers/audio/ak4537.c
+++ b/firmware/drivers/audio/ak4537.c
@@ -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);
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c
index e1c7f65..1f79277 100644
--- a/firmware/drivers/audio/as3514.c
+++ b/firmware/drivers/audio/as3514.c
@@ -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;
}
}
diff --git a/firmware/drivers/audio/cs42l55.c b/firmware/drivers/audio/cs42l55.c
index 6c6e17a..02c80da 100644
--- a/firmware/drivers/audio/cs42l55.c
+++ b/firmware/drivers/audio/cs42l55.c
@@ -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;
}
diff --git a/firmware/drivers/audio/dummy_codec.c b/firmware/drivers/audio/dummy_codec.c
index 3e73137..fbbe836 100644
--- a/firmware/drivers/audio/dummy_codec.c
+++ b/firmware/drivers/audio/dummy_codec.c
@@ -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 */
diff --git a/firmware/drivers/audio/rk27xx_codec.c b/firmware/drivers/audio/rk27xx_codec.c
index 8f294ba..2b0f2db 100644
--- a/firmware/drivers/audio/rk27xx_codec.c
+++ b/firmware/drivers/audio/rk27xx_codec.c
@@ -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 */
diff --git a/firmware/drivers/audio/sdl.c b/firmware/drivers/audio/sdl.c
index c14ba0c..f35cec8 100644
--- a/firmware/drivers/audio/sdl.c
+++ b/firmware/drivers/audio/sdl.c
@@ -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 */
diff --git a/firmware/drivers/audio/tlv320.c b/firmware/drivers/audio/tlv320.c
index 6118734..9fa676f 100644
--- a/firmware/drivers/audio/tlv320.c
+++ b/firmware/drivers/audio/tlv320.c
@@ -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);
diff --git a/firmware/drivers/audio/tsc2100.c b/firmware/drivers/audio/tsc2100.c
index fda192a..b74d445 100644
--- a/firmware/drivers/audio/tsc2100.c
+++ b/firmware/drivers/audio/tsc2100.c
@@ -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));
}
}
diff --git a/firmware/drivers/audio/uda1341.c b/firmware/drivers/audio/uda1341.c
index e15cd39..7557310 100644
--- a/firmware/drivers/audio/uda1341.c
+++ b/firmware/drivers/audio/uda1341.c
@@ -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;
diff --git a/firmware/drivers/audio/wm8731.c b/firmware/drivers/audio/wm8731.c
index f84edc5..5c1e623 100644
--- a/firmware/drivers/audio/wm8731.c
+++ b/firmware/drivers/audio/wm8731.c
@@ -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);
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c
index feba05e..476c6c3 100644
--- a/firmware/drivers/audio/wm8751.c
+++ b/firmware/drivers/audio/wm8751.c
@@ -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;
diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c
index 3f3ac79..f7d7a5b 100644
--- a/firmware/drivers/audio/wm8758.c
+++ b/firmware/drivers/audio/wm8758.c
@@ -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);
diff --git a/firmware/drivers/audio/wm8975.c b/firmware/drivers/audio/wm8975.c
index 4905445..931dae9 100644
--- a/firmware/drivers/audio/wm8975.c
+++ b/firmware/drivers/audio/wm8975.c
@@ -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);
diff --git a/firmware/drivers/audio/wm8978.c b/firmware/drivers/audio/wm8978.c
index 3a86ef2..69ae608 100644
--- a/firmware/drivers/audio/wm8978.c
+++ b/firmware/drivers/audio/wm8978.c
@@ -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)
diff --git a/firmware/drivers/audio/wm8985.c b/firmware/drivers/audio/wm8985.c
index 2d49e70..fab7354 100644
--- a/firmware/drivers/audio/wm8985.c
+++ b/firmware/drivers/audio/wm8985.c
@@ -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;
}
}