mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Implement universal in-PCM-driver software volume control.
Implements double-buffered volume, balance and prescaling control in the main PCM driver when HAVE_SW_VOLUME_CONTROL is defined ensuring that all PCM is volume controlled and level changes are low in latency. Supports -73 to +6 dB using a 15-bit factor so that no large-integer math is needed. Low-level hardware drivers do not have to implement it themselves but parameters can be changed (currently defined in pcm-internal.h) to work best with a particular SoC or to provide different volume ranges. Volume and prescale calls should be made in the codec driver. It should appear as a normal hardware interface. PCM volume calls expect .1 dB units. Change-Id: Idf6316a64ef4fb8abcede10707e1e6c6d01d57db Reviewed-on: http://gerrit.rockbox.org/423 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
This commit is contained in:
parent
a9049a79d7
commit
f5a5b94686
13 changed files with 478 additions and 156 deletions
|
@ -26,6 +26,9 @@
|
|||
#include "logf.h"
|
||||
#include "system.h"
|
||||
#include "i2c.h"
|
||||
#ifdef HAVE_SW_VOLUME_CONTROL
|
||||
#include "pcm_sw_volume.h"
|
||||
#endif /* HAVE_SW_VOLUME_CONTROL */
|
||||
|
||||
/* TODO
|
||||
* find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble
|
||||
|
@ -215,7 +218,7 @@ static void set_prescaled_volume(void)
|
|||
dsp_callback(DSP_CALLBACK_SET_PRESCALE, prescale);
|
||||
#endif
|
||||
|
||||
if (current_volume == VOLUME_MIN)
|
||||
if (current_volume <= VOLUME_MIN)
|
||||
prescale = 0; /* Make sure the chip gets muted at VOLUME_MIN */
|
||||
|
||||
l = r = current_volume + prescale;
|
||||
|
@ -231,13 +234,11 @@ static void set_prescaled_volume(void)
|
|||
r += ((r - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SW_VOLUME_CONTROL
|
||||
dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0);
|
||||
#endif
|
||||
|
||||
/* ypr0 with sdl has separate volume controls */
|
||||
#if !defined(HAVE_SDL_AUDIO) || defined(SAMSUNG_YPR0)
|
||||
#if CONFIG_CODEC == MAS3507D
|
||||
#if defined(HAVE_SW_VOLUME_CONTROL) || defined(HAVE_JZ4740_CODEC)
|
||||
audiohw_set_master_vol(l, r);
|
||||
#elif CONFIG_CODEC == MAS3507D
|
||||
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
|
||||
#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
|
||||
|| defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
|
||||
|
@ -253,7 +254,7 @@ static void set_prescaled_volume(void)
|
|||
|
||||
#elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985) || defined(HAVE_IMX233_CODEC) || defined(HAVE_AIC3X)
|
||||
audiohw_set_headphone_vol(tenthdb2master(l), tenthdb2master(r));
|
||||
#elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO) || defined(ANDROID)
|
||||
#elif defined(HAVE_SDL_AUDIO) || defined(ANDROID)
|
||||
audiohw_set_volume(current_volume);
|
||||
#endif
|
||||
#else /* HAVE_SDL_AUDIO */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue