From 37cbf38ee526055a1f502356eea9e7a372a1b67c Mon Sep 17 00:00:00 2001 From: Raghu Bankapur Date: Thu, 1 Dec 2022 09:30:00 +0530 Subject: [PATCH] HAL: Converting PCM enum to AUDIO FORMAT enum Add function for PCM FORMAT enum to AUDIO FORMAT enum conversion. Change-Id: I0fc3c1adfe3aec6b309b790db8be537d50cee0ae Signed-off-by: Raghu Bankapur --- hal/audio_hw.c | 2 +- hal/audio_hw.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 554b6242..ab9536cc 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -7188,7 +7188,7 @@ static size_t in_get_buffer_size(const struct audio_stream *stream) if(in->usecase == USECASE_COMPRESS_VOIP_CALL) return voice_extn_compress_voip_in_get_buffer_size(in); else if(audio_extn_compr_cap_usecase_supported(in->usecase)) - return audio_extn_compr_cap_get_buffer_size(in->config.format); + return audio_extn_compr_cap_get_buffer_size(pcm_format_to_audio_format(in->config.format)); else if(audio_extn_cin_attached_usecase(in)) return audio_extn_cin_get_buffer_size(in); diff --git a/hal/audio_hw.h b/hal/audio_hw.h index d24202c6..058d7a27 100644 --- a/hal/audio_hw.h +++ b/hal/audio_hw.h @@ -947,4 +947,29 @@ audio_patch_handle_t generate_patch_handle(); * and latch at last. */ +static inline audio_format_t pcm_format_to_audio_format(const enum pcm_format format) +{ + audio_format_t ret = AUDIO_FORMAT_INVALID; + switch(format) { + case PCM_FORMAT_S16_LE: + ret = (audio_format_t)AUDIO_FORMAT_PCM_SUB_16_BIT; + break; + case PCM_FORMAT_S32_LE: + ret = (audio_format_t)AUDIO_FORMAT_PCM_SUB_32_BIT; + break; + case PCM_FORMAT_S8: + ret = (audio_format_t)AUDIO_FORMAT_PCM_SUB_8_BIT; + break; + case PCM_FORMAT_S24_LE: + ret = (audio_format_t)AUDIO_FORMAT_PCM_SUB_8_24_BIT; + break; + case PCM_FORMAT_S24_3LE: + ret = (audio_format_t)AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED; + break; + default: + break; + } + return ret; +} + #endif // QCOM_AUDIO_HW_H