Audio: Volume: Handle all volume ramp types

The windows fade, windows no fade, and linear and handled
the switch-case statement change into volume.c.

In IPC4 the ramp can be disabled with zero curve duration or with
no fade type. The ramp duration convert multiplication can be passed
with the no fade type.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2023-09-20 15:25:42 +03:00 committed by Kai Vehmanen
parent 4b9d10e5f1
commit 8f9c68ae57
2 changed files with 21 additions and 12 deletions

View File

@ -283,18 +283,22 @@ static inline void volume_ramp(struct processing_module *mod)
* calculated from previous gain and ramp time. The slope
* coefficient is calculated in volume_set_chan().
*/
#if defined CONFIG_COMP_VOLUME_WINDOWS_FADE && defined CONFIG_COMP_VOLUME_LINEAR_RAMP
if (cd->ramp_type == SOF_VOLUME_WINDOWS_FADE)
switch (cd->ramp_type) {
#if CONFIG_COMP_VOLUME_WINDOWS_FADE
case SOF_VOLUME_WINDOWS_FADE:
new_vol = volume_windows_fade_ramp(cd, ramp_time, i);
else
new_vol = volume_linear_ramp(cd, ramp_time, i);
#elif defined CONFIG_COMP_VOLUME_WINDOWS_FADE
new_vol = volume_windows_fade_ramp(cd, ramp_time, i);
#elif defined CONFIG_COMP_VOLUME_LINEAR_RAMP
new_vol = volume_linear_ramp(cd, ramp_time, i);
#else
new_vol = tvolume;
break;
#endif
#if CONFIG_COMP_VOLUME_LINEAR_RAMP
case SOF_VOLUME_LINEAR:
case SOF_VOLUME_LINEAR_ZC:
new_vol = volume_linear_ramp(cd, ramp_time, i);
break;
#endif
default:
new_vol = tvolume;
}
if (volume < tvolume) {
/* ramp up, check if ramp completed */
if (new_vol < tvolume)

View File

@ -86,8 +86,13 @@ static void init_ramp(struct vol_data *cd, uint32_t curve_duration, uint32_t tar
/* In IPC4 driver sends curve_duration in hundred of ns - it should be
* converted into ms value required by firmware
*/
cd->initial_ramp = Q_MULTSR_32X32((int64_t)curve_duration,
Q_CONVERT_FLOAT(1.0 / 10000, 31), 0, 31, 0);
if (cd->ramp_type == SOF_VOLUME_WINDOWS_NO_FADE) {
cd->initial_ramp = 0;
cd->ramp_finished = true;
} else {
cd->initial_ramp = Q_MULTSR_32X32((int64_t)curve_duration,
Q_CONVERT_FLOAT(1.0 / 10000, 31), 0, 31, 0);
}
if (!cd->initial_ramp) {
/* In case when initial ramp time is equal to zero, vol_min and