Skip to content

Commit c8b8dd7

Browse files
committed
Audio: Cadence: Add an open-source PCM decoder
This patch adds a PCM decoder that is compatible with Cadence codec API. It allows to test tinycompress cplay playback with wav format files. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 96ab79a commit c8b8dd7

File tree

9 files changed

+511
-0
lines changed

9 files changed

+511
-0
lines changed

src/audio/base_fw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ static void get_codec_info(struct sof_tlv **tuple)
9999
codec_info.items[codec_info.count++] =
100100
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_VORBIS, SOF_IPC_STREAM_PLAYBACK);
101101
#endif
102+
#ifdef CONFIG_SOF_COMPRESS_CODEC_PCM_DEC
103+
codec_info.items[codec_info.count++] =
104+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_PCM, SOF_IPC_STREAM_PLAYBACK);
105+
#endif
102106

103107
if (!codec_info.count)
104108
return;

src/audio/module_adapter/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ endif()
3333
zephyr_library_import(xa_mp3_enc ${CONFIG_CADENCE_CODEC_MP3_ENC_LIB})
3434
endif()
3535

36+
zephyr_library_sources_ifdef(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC
37+
module/cadence_other/xa_pcm_dec.c)
38+
3639
if (CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING)
3740
if(CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING STREQUAL "m" AND DEFINED CONFIG_LLEXT)
3841
add_subdirectory(module/dolby/llext
@@ -147,6 +150,10 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD)
147150

148151
endif()
149152

153+
if(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC)
154+
add_subdirectory(module/cadence_other)
155+
endif()
156+
150157
if(CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING)
151158
target_include_directories(sof PRIVATE ${PROJECT_SOURCE_DIR}/third_party/include)
152159
add_local_sources(sof module/dolby/dax.c)

src/audio/module_adapter/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ if CADENCE_CODEC
173173
This option is a string and takes the full name of the SRC library binary.
174174
endif
175175

176+
config SOF_COMPRESS_CODEC_PCM_DEC
177+
bool "SOF PCM (WAV) decoder"
178+
help
179+
Select to enable PCM (WAV) decoder.
180+
This provides PCM/WAV file decoding support through a simple
181+
implementation that handles the PCM data. Note that this is not
182+
a Cadence codec module but an open-source addition to support the
183+
PCM data format. In addition need to build the cplay from
184+
tinycompress with option --enable-pcm to use this.
185+
176186
endif # Cadence
177187

178188
config COMP_DOLBY_DAX_AUDIO_PROCESSING

src/audio/module_adapter/module/cadence.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ struct cadence_api cadence_api_table[] = {
7474
.api = xa_src_pp,
7575
},
7676
#endif
77+
#ifdef CONFIG_SOF_COMPRESS_CODEC_PCM_DEC
78+
{
79+
.id = SOF_COMPRESS_CODEC_PCM_DEC_ID,
80+
.api = xa_pcm_dec,
81+
},
82+
#endif
7783
};
7884

7985
static int cadence_codec_get_api_id(uint32_t compress_id, uint32_t direction)
@@ -89,6 +95,8 @@ static int cadence_codec_get_api_id(uint32_t compress_id, uint32_t direction)
8995
return CADENCE_CODEC_AAC_DEC_ID;
9096
case SND_AUDIOCODEC_VORBIS:
9197
return CADENCE_CODEC_VORBIS_DEC_ID;
98+
case SND_AUDIOCODEC_PCM:
99+
return SOF_COMPRESS_CODEC_PCM_DEC_ID;
92100
default:
93101
return -EINVAL;
94102
}
@@ -236,6 +244,9 @@ int cadence_codec_get_samples(struct processing_module *mod)
236244
return 1152;
237245
case CADENCE_CODEC_AAC_DEC_ID:
238246
return 1024;
247+
case SOF_COMPRESS_CODEC_PCM_DEC_ID:
248+
/* Not critical for PCM, use 1024 for consistency */
249+
return 1024;
239250
default:
240251
break;
241252
}

src/audio/module_adapter/module/cadence_ipc4.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ static int cadence_configure_codec_params(struct processing_module *mod)
209209
case CADENCE_CODEC_VORBIS_DEC_ID:
210210
/* No configuration needed for Vorbis */
211211
return 0;
212+
case SOF_COMPRESS_CODEC_PCM_DEC_ID:
213+
/* No configuration needed for PCM decoder */
214+
return 0;
212215
default:
213216
break;
214217
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
if(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC)
4+
add_local_sources(sof xa_pcm_dec.c)
5+
endif()

0 commit comments

Comments
 (0)