diff options
author | Tzung-Bi Shih <tzungbi@chromium.org> | 2019-06-29 07:25:46 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-19 07:59:11 +0000 |
commit | 8fe3e6a850f06b499cc60834a925736ce95171d9 (patch) | |
tree | fdecb38045e7e18336e678d2614f7b649bcda733 /common | |
parent | e0d9bb6fdef6fe87dac52ea7f26281f8d3239a7a (diff) | |
download | chrome-ec-8fe3e6a850f06b499cc60834a925736ce95171d9.tar.gz |
chip/mt_scp: support software gain
Multiply the audio data by a gain value. Note that it get muted when
gain is 0.
BRANCH=none
BUG=b:122027734, b:123268236
TEST=1. define CONFIG_AUDIO_CODEC in board.h
2. define CONFIG_AUDIO_CODEC_DMIC in board.h
3. define CONFIG_AUDIO_CODEC_DMIC_SOFTWARE_GAIN in board.h
4. define CONFIG_AUDIO_CODEC_DMIC_MAX_SOFTWARE_GAIN in board.h
5. define CONFIG_AUDIO_CODEC_WOV in board.h
6. make BOARD=kukui_scp -j
Change-Id: I8c308ffb6d7c8f5bd378524bdffc980d7b9948fa
Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1683028
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/audio_codec.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/common/audio_codec.c b/common/audio_codec.c index e21df5c039..43ba520707 100644 --- a/common/audio_codec.c +++ b/common/audio_codec.c @@ -7,6 +7,7 @@ #include "audio_codec.h" #include "console.h" #include "host_command.h" +#include "util.h" #define CPRINTS(format, args...) cprints(CC_AUDIO_CODEC, format, ## args) @@ -144,3 +145,13 @@ int audio_codec_memmap_ap_to_ec(uintptr_t ap_addr, uintptr_t *ec_addr) { return EC_ERROR_UNIMPLEMENTED; } + +int16_t audio_codec_s16_scale_and_clip(int16_t orig, uint8_t scalar) +{ + int32_t val; + + val = (int32_t)orig * (int32_t)scalar; + val = MIN(val, (int32_t)INT16_MAX); + val = MAX(val, (int32_t)INT16_MIN); + return val; +} |