Skip to content

Commit 7d500e6

Browse files
committed
ipc: compress: add aptX HD, ITU-T G.726, and ITU-T G.711 codec IDs
Define SND_AUDIOCODEC_APTX_HD (0x15), SND_AUDIOCODEC_G726 (0x16), SND_AUDIOCODEC_ALAW (0x17), and SND_AUDIOCODEC_MULAW (0x18) in compress_params.h and advance SND_AUDIOCODEC_MAX. Advertise playback/capture support for the new codecs in base_fw.c get_codec_info() with bounds-checked helper add_codec_info_item(), and extend the BESPOKE capability guards to cover them. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 5321949 commit 7d500e6

2 files changed

Lines changed: 54 additions & 9 deletions

File tree

‎src/include/ipc/compress_params.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@
8181
#define SND_AUDIOCODEC_SBC ((uint32_t) 0x00000012)
8282
#define SND_AUDIOCODEC_G722 ((uint32_t) 0x00000013)
8383
#define SND_AUDIOCODEC_APTX ((uint32_t) 0x00000014)
84-
#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_APTX
84+
#define SND_AUDIOCODEC_APTX_HD ((uint32_t) 0x00000015)
85+
#define SND_AUDIOCODEC_G726 ((uint32_t) 0x00000016)
86+
#define SND_AUDIOCODEC_ALAW ((uint32_t) 0x00000017)
87+
#define SND_AUDIOCODEC_MULAW ((uint32_t) 0x00000018)
88+
#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_MULAW
8589

8690
/*
8791
* Profile and modes are listed with bit masks. This allows for a

‎src/kernel/audio/base_fw.c‎

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ struct sof_ipc4_codec_info_data {
8686
*/
8787
#define SET_CODEC_INFO_ITEM(codec, dir) (((codec) & 0xff) | (((dir) & 0xf) << 8))
8888

89+
static inline void add_codec_info_item(struct sof_ipc4_codec_info_data *info,
90+
uint32_t codec, uint32_t dir)
91+
{
92+
if (info->count < ARRAY_SIZE(info->items)) {
93+
info->items[info->count++] = SET_CODEC_INFO_ITEM(codec, dir);
94+
}
95+
}
96+
8997
static void get_codec_info(struct sof_tlv **tuple)
9098
{
9199
struct sof_ipc4_codec_info_data codec_info = { 0 };
@@ -190,23 +198,56 @@ static void get_codec_info(struct sof_tlv **tuple)
190198
codec_info.items[codec_info.count++] =
191199
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_APTX, SOF_IPC_STREAM_CAPTURE);
192200
#endif
201+
#if defined(CONFIG_FFMPEG_DEC_APTX_HD)
202+
/* Bluetooth aptX HD decode via ffmpeg_dec (native libavcodec). */
203+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_APTX_HD, SOF_IPC_STREAM_PLAYBACK);
204+
#endif
205+
#if defined(CONFIG_FFMPEG_ENC_APTX_HD)
206+
/* Bluetooth aptX HD encode via ffmpeg_enc (native libavcodec). */
207+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_APTX_HD, SOF_IPC_STREAM_CAPTURE);
208+
#endif
209+
#if defined(CONFIG_FFMPEG_DEC_G726)
210+
/* ITU-T G.726 ADPCM decode via ffmpeg_dec (native libavcodec). */
211+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_G726, SOF_IPC_STREAM_PLAYBACK);
212+
#endif
213+
#if defined(CONFIG_FFMPEG_ENC_G726)
214+
/* ITU-T G.726 ADPCM encode via ffmpeg_enc (native libavcodec). */
215+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_G726, SOF_IPC_STREAM_CAPTURE);
216+
#endif
217+
#if defined(CONFIG_FFMPEG_DEC_ALAW)
218+
/* ITU-T G.711 A-law decode via ffmpeg_dec (native libavcodec). */
219+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_ALAW, SOF_IPC_STREAM_PLAYBACK);
220+
#endif
221+
#if defined(CONFIG_FFMPEG_ENC_ALAW)
222+
/* ITU-T G.711 A-law encode via ffmpeg_enc (native libavcodec). */
223+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_ALAW, SOF_IPC_STREAM_CAPTURE);
224+
#endif
225+
#if defined(CONFIG_FFMPEG_DEC_MULAW)
226+
/* ITU-T G.711 mu-law decode via ffmpeg_dec (native libavcodec). */
227+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_MULAW, SOF_IPC_STREAM_PLAYBACK);
228+
#endif
229+
#if defined(CONFIG_FFMPEG_ENC_MULAW)
230+
/* ITU-T G.711 mu-law encode via ffmpeg_enc (native libavcodec). */
231+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_MULAW, SOF_IPC_STREAM_CAPTURE);
232+
#endif
193233
#if (defined(CONFIG_FFMPEG_ENC_SBC) || defined(CONFIG_FFMPEG_ENC_G722) || \
194-
defined(CONFIG_FFMPEG_ENC_APTX)) && !defined(CONFIG_COMP_MFCC)
234+
defined(CONFIG_FFMPEG_ENC_APTX) || defined(CONFIG_FFMPEG_ENC_APTX_HD) || \
235+
defined(CONFIG_FFMPEG_ENC_G726) || defined(CONFIG_FFMPEG_ENC_ALAW) || \
236+
defined(CONFIG_FFMPEG_ENC_MULAW)) && !defined(CONFIG_COMP_MFCC)
195237
/* Also advertise BESPOKE capture for kernels with older SND_AUDIOCODEC_MAX. */
196-
codec_info.items[codec_info.count++] =
197-
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_BESPOKE, SOF_IPC_STREAM_CAPTURE);
238+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_BESPOKE, SOF_IPC_STREAM_CAPTURE);
198239
#endif
199240
#ifdef CONFIG_FFMPEG_DEC_OPUS
200241
/* Opus decode is provided by the ffmpeg_dec (libavcodec) module.
201242
* Advertise OPUS_RAW and BESPOKE.
202243
*/
203-
codec_info.items[codec_info.count++] =
204-
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_OPUS_RAW, SOF_IPC_STREAM_PLAYBACK);
244+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_OPUS_RAW, SOF_IPC_STREAM_PLAYBACK);
205245
#endif
206246
#if defined(CONFIG_FFMPEG_DEC_OPUS) || defined(CONFIG_FFMPEG_DEC_SBC) || \
207-
defined(CONFIG_FFMPEG_DEC_G722) || defined(CONFIG_FFMPEG_DEC_APTX)
208-
codec_info.items[codec_info.count++] =
209-
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_BESPOKE, SOF_IPC_STREAM_PLAYBACK);
247+
defined(CONFIG_FFMPEG_DEC_G722) || defined(CONFIG_FFMPEG_DEC_APTX) || \
248+
defined(CONFIG_FFMPEG_DEC_APTX_HD) || defined(CONFIG_FFMPEG_DEC_G726) || \
249+
defined(CONFIG_FFMPEG_DEC_ALAW) || defined(CONFIG_FFMPEG_DEC_MULAW)
250+
add_codec_info_item(&codec_info, SND_AUDIOCODEC_BESPOKE, SOF_IPC_STREAM_PLAYBACK);
210251
#endif
211252

212253
if (!codec_info.count)

0 commit comments

Comments
 (0)