erosq: Tweak volume scale to be approximately correct

Tested on eros q, everything measured from line out,
open circuit.

- volume steps were approximately double the dB they
  were labelled as, so "-2 dB" would result in a change
  of about -4 dB from maximum (0, +6.2dBV)
- maximum volume defining the line out volume only
  changed every 10 values, and then was not close
  to correct- "-10 dB" resulted in -2.5 dB from maximum

This gets the volume dB approximately correct, and
maximum volume correctly sets the line out volume.
I was unable to get odd values in the max volume
to work, so set the step size to 2 instead of one.

For "consumer level" (-10dBV), set to -16.
For "Pro level" (+4dBu -> ~1.8dBV), set to -4.

Change-Id: I898b85d768153579a893b23551019af88f865d21
This commit is contained in:
Dana Conrad 2021-04-13 20:59:45 -05:00 committed by Solomon Peachy
parent a9d3e9a13d
commit 4dc602dd7f
2 changed files with 6 additions and 6 deletions

View file

@ -151,7 +151,7 @@ void audiohw_set_frequency(int fsel)
} }
/* min/max for pcm volume */ /* min/max for pcm volume */
const int min_pcm = -430; const int min_pcm = -740;
const int max_pcm = 0; const int max_pcm = 0;
void audiohw_set_volume(int vol_l, int vol_r) void audiohw_set_volume(int vol_l, int vol_r)
@ -169,7 +169,7 @@ void audiohw_set_volume(int vol_l, int vol_r)
output gain, we have to back off on the PCM signal output gain, we have to back off on the PCM signal
to avoid blowing out the signal. to avoid blowing out the signal.
*/ */
l = r = global_settings.volume_limit; l = r = global_settings.volume_limit * 10;
} else { } else {
l = vol_l_hw; l = vol_l_hw;
r = vol_r_hw; r = vol_r_hw;
@ -177,7 +177,7 @@ void audiohw_set_volume(int vol_l, int vol_r)
int sw_volume_l = l <= min_pcm ? min_pcm : MIN(l, max_pcm); int sw_volume_l = l <= min_pcm ? min_pcm : MIN(l, max_pcm);
int sw_volume_r = r <= min_pcm ? min_pcm : MIN(r, max_pcm); int sw_volume_r = r <= min_pcm ? min_pcm : MIN(r, max_pcm);
pcm_set_mixer_volume(sw_volume_l / 10, sw_volume_r / 10); pcm_set_mixer_volume(sw_volume_l / 20, sw_volume_r / 20);
} }
void audiohw_set_lineout_volume(int vol_l, int vol_r) void audiohw_set_lineout_volume(int vol_l, int vol_r)
@ -190,7 +190,7 @@ void audiohw_set_lineout_volume(int vol_l, int vol_r)
(void)vol_r; (void)vol_r;
if (lineout_inserted()) { if (lineout_inserted()) {
l = r = global_settings.volume_limit; l = r = global_settings.volume_limit * 10;
} else { } else {
l = vol_l_hw; l = vol_l_hw;
r = vol_r_hw; r = vol_r_hw;
@ -198,5 +198,5 @@ void audiohw_set_lineout_volume(int vol_l, int vol_r)
int sw_volume_l = l <= min_pcm ? min_pcm : MIN(l, max_pcm); int sw_volume_l = l <= min_pcm ? min_pcm : MIN(l, max_pcm);
int sw_volume_r = r <= min_pcm ? min_pcm : MIN(r, max_pcm); int sw_volume_r = r <= min_pcm ? min_pcm : MIN(r, max_pcm);
pcm_set_mixer_volume(sw_volume_l / 10, sw_volume_r / 10); pcm_set_mixer_volume(sw_volume_l / 20, sw_volume_r / 20);
} }

View file

@ -3,7 +3,7 @@
#define AUDIOHW_CAPS (LINEOUT_CAP) #define AUDIOHW_CAPS (LINEOUT_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -43, 0, -20) AUDIOHW_SETTING(VOLUME, "dB", 0, 2, -74, 0, -40)
//#define AUDIOHW_NEEDS_INITIAL_UNMUTE //#define AUDIOHW_NEEDS_INITIAL_UNMUTE