Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion src/audio/ffmpeg_dec/ffmpeg_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// ffmpeg_dec-stub.c and ffmpeg_dec-ffmpeg.c). The input is a compressed audio
// elementary stream (raw data), the output is interleaved PCM.

#include <sof/audio/codec_info.h>
#include <sof/audio/module_adapter/module/generic.h>
#include <sof/audio/sink_api.h>
#include <sof/audio/sink_source_utils.h>
Expand Down Expand Up @@ -967,6 +968,71 @@ static const struct module_interface ffmpeg_dec_interface = {
.free = ffmpeg_dec_free
};

static const uint32_t ffmpeg_dec_codec_info_items[]
#if CONFIG_COMP_FFMPEG_DEC_MODULE
__section(SOF_CODEC_INFO_SECTION) __used
#endif
= {
#if defined(CONFIG_FFMPEG_FILTER)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_PCM, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_DEC_FLAC) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_FLAC, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_DEC_ALAC) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_ALAC, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_DEC_AAC) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_AAC, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_DEC_MP3) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_ENC_MP3)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_ENC_AAC)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_AAC, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_ENC_FLAC)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_FLAC, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_ENC_ALAC)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_ALAC, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_DEC_SBC) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_SBC, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_ENC_SBC)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_SBC, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_DEC_G722) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_G722, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_ENC_G722)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_G722, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_DEC_APTX) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_APTX, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_ENC_APTX)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_APTX, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_ENC_SBC) || defined(CONFIG_FFMPEG_ENC_G722) || \
defined(CONFIG_FFMPEG_ENC_APTX)
/* Also advertise BESPOKE capture for kernels with older SND_AUDIOCODEC_MAX. */
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_BESPOKE, SOF_IPC_STREAM_CAPTURE),
#endif
#if defined(CONFIG_FFMPEG_DEC_OPUS) || defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_OPUS_RAW, SOF_IPC_STREAM_PLAYBACK),
#endif
#if defined(CONFIG_FFMPEG_DEC_OPUS) || defined(CONFIG_FFMPEG_DEC_SBC) || \
defined(CONFIG_FFMPEG_DEC_G722) || defined(CONFIG_FFMPEG_DEC_APTX) || \
defined(CONFIG_COMP_FFMPEG_DEC_STUB)
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_BESPOKE, SOF_IPC_STREAM_PLAYBACK),
#endif
};

/* If COMP_FFMPEG_DEC is =m in Kconfig this is built as a loadable LLEXT module. */
#if CONFIG_COMP_FFMPEG_DEC_MODULE

Expand All @@ -985,6 +1051,14 @@ SOF_LLEXT_BUILDINFO;
/* Only used for the module adapter trace context, soon to be deprecated */
DECLARE_TR_CTX(ffmpeg_dec_tr, SOF_UUID(ffmpeg_dec_uuid), LOG_LEVEL_INFO);
DECLARE_MODULE_ADAPTER(ffmpeg_dec_interface, ffmpeg_dec_uuid, ffmpeg_dec_tr);
SOF_MODULE_INIT(ffmpeg_dec, sys_comp_module_ffmpeg_dec_interface_init);

static void sys_comp_ffmpeg_dec_init(void)
{
sys_comp_module_ffmpeg_dec_interface_init();
sof_codec_info_register(&ffmpeg_dec_interface, ffmpeg_dec_codec_info_items,
ARRAY_SIZE(ffmpeg_dec_codec_info_items));
}

SOF_MODULE_INIT(ffmpeg_dec, sys_comp_ffmpeg_dec_init);

#endif
20 changes: 19 additions & 1 deletion src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>

#include <sof/audio/codec_info.h>
#include <sof/audio/mfcc/mfcc_comp.h>
#include <sof/audio/module_adapter/module/generic.h>
#include <sof/audio/component.h>
Expand All @@ -21,6 +22,7 @@
#include <sof/list.h>
#include <sof/ut.h>
#include <sof/trace/trace.h>
#include <ipc/compress_params.h>
#include <ipc/control.h>
#include <ipc/stream.h>
#include <ipc/topology.h>
Expand Down Expand Up @@ -321,6 +323,14 @@ static const struct module_interface mfcc_interface = {
.reset = mfcc_reset,
};

static const uint32_t mfcc_codec_info_items[]
#if CONFIG_COMP_MFCC_MODULE
__section(SOF_CODEC_INFO_SECTION) __used
#endif
= {
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_BESPOKE, SOF_IPC_STREAM_CAPTURE),
};

#if CONFIG_COMP_MFCC_MODULE
/* modular: llext dynamic link */

Expand All @@ -338,6 +348,14 @@ SOF_LLEXT_BUILDINFO;
/* unused with Zephyr, generates no output */
DECLARE_TR_CTX(mfcc_tr, SOF_UUID(mfcc_uuid), LOG_LEVEL_INFO);
DECLARE_MODULE_ADAPTER(mfcc_interface, mfcc_uuid, mfcc_tr);
SOF_MODULE_INIT(mfcc, sys_comp_module_mfcc_interface_init);

static void sys_comp_mfcc_init(void)
{
sys_comp_module_mfcc_interface_init();
sof_codec_info_register(&mfcc_interface, mfcc_codec_info_items,
ARRAY_SIZE(mfcc_codec_info_items));
}

SOF_MODULE_INIT(mfcc, sys_comp_mfcc_init);

#endif
37 changes: 36 additions & 1 deletion src/audio/module_adapter/module/cadence_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright(c) 2025-2026 Intel Corporation. All rights reserved.
//

#include <sof/audio/codec_info.h>
#include <sof/audio/module_adapter/module/generic.h>
#include <sof/audio/module_adapter/module/cadence.h>
#include <sof/audio/cadence/mp3_dec/xa_mp3_dec_api.h>
Expand Down Expand Up @@ -644,4 +645,38 @@ static const struct module_interface cadence_codec_interface = {
};

DECLARE_MODULE_ADAPTER(cadence_codec_interface, cadence_codec_uuid, cadence_codec_tr);
SOF_MODULE_INIT(cadence_codec, sys_comp_module_cadence_codec_interface_init);

#if defined(CONFIG_CADENCE_CODEC_AAC_DEC) || defined(CONFIG_CADENCE_CODEC_MP3_DEC) || \
defined(CONFIG_CADENCE_CODEC_MP3_ENC) || defined(CONFIG_CADENCE_CODEC_VORBIS_DEC) || \
defined(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC)
static const uint32_t cadence_codec_info_items[] = {
#ifdef CONFIG_CADENCE_CODEC_AAC_DEC
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_AAC, SOF_IPC_STREAM_PLAYBACK),
#endif
#ifdef CONFIG_CADENCE_CODEC_MP3_DEC
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_PLAYBACK),
#endif
#ifdef CONFIG_CADENCE_CODEC_MP3_ENC
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_CAPTURE),
#endif
#ifdef CONFIG_CADENCE_CODEC_VORBIS_DEC
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_VORBIS, SOF_IPC_STREAM_PLAYBACK),
#endif
#ifdef CONFIG_SOF_COMPRESS_CODEC_PCM_DEC
SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_PCM, SOF_IPC_STREAM_PLAYBACK),
#endif
};
#endif

static void sys_comp_cadence_codec_init(void)
{
sys_comp_module_cadence_codec_interface_init();
#if defined(CONFIG_CADENCE_CODEC_AAC_DEC) || defined(CONFIG_CADENCE_CODEC_MP3_DEC) || \
defined(CONFIG_CADENCE_CODEC_MP3_ENC) || defined(CONFIG_CADENCE_CODEC_VORBIS_DEC) || \
defined(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC)
sof_codec_info_register(&cadence_codec_interface, cadence_codec_info_items,
ARRAY_SIZE(cadence_codec_info_items));
#endif
}

SOF_MODULE_INIT(cadence_codec, sys_comp_cadence_codec_init);
8 changes: 8 additions & 0 deletions src/include/ipc4/base_fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ enum ipc4_basefw_params {

/** Set policy mask for microphone privacy in firmware-managed mode. */
IPC4_SET_MIC_PRIVACY_FW_MANAGED_POLICY_MASK = 36,

/** Discover SOF specific runtime capabilities/information in TLV format via LARGE_CONFIG_GET. */
IPC4_SOF_INFO_GET = 37,
};

/**
Expand Down Expand Up @@ -289,13 +292,18 @@ enum ipc4_fw_config_params {
enum ipc4_fw_sof_info_params {
/** Decoder/encoder codec information. */
IPC4_SOF_CODEC_INFO = 0,
/** Bitmask of runtime SOF info capabilities (IPC4_SOF_CAP_*). */
IPC4_SOF_CAPS = 1,

/** Total number of SOF config parameters. */
IPC4_SOF_CFG_PARAMS_COUNT,
/** Maximum SOF config parameter ID value. */
IPC4_MAX_SOF_CFG_PARAM = IPC4_SOF_CFG_PARAMS_COUNT - 1,
};

/** BaseFW supports runtime query via IPC4_SOF_INFO_GET. */
#define IPC4_SOF_CAP_RUNTIME_SOF_INFO (1U << 0)

/**
* \brief Hardware configuration parameter TLV IDs returned by IPC4_HW_CONFIG_GET.
* \ingroup ipc4_base_fw_api
Expand Down
54 changes: 54 additions & 0 deletions src/include/sof/audio/codec_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright(c) 2026 Intel Corporation. All rights reserved.
*/

#ifndef __SOF_AUDIO_CODEC_INFO_H__
#define __SOF_AUDIO_CODEC_INFO_H__

#include <stdint.h>

/**
* \brief Encodes codec and direction information into a single 32-bit value.
* \param codec Codec type (bits 0-7, e.g. SND_AUDIOCODEC_*)
* \param dir Stream direction (bits 8-11, e.g. SOF_IPC_STREAM_*)
* \return Encoded 32-bit codec capability item
*/
#define SOF_CODEC_INFO_ITEM(codec, dir) \
(((uint32_t)(codec) & 0xffU) | (((uint32_t)(dir) & 0xfU) << 8))

/** ELF section name holding LLEXT module codec capability items. */
#define SOF_CODEC_INFO_SECTION ".sof_codec_info"

#if CONFIG_COMP_BASEFW_IPC4 && !CONFIG_LIBRARY
/**
* \brief Register runtime codec audio capabilities for a module or library.
* \param[in] owner Opaque owner token (e.g. module interface or library module ctx).
* \param[in] items Array of SOF_CODEC_INFO_ITEM(codec, dir) values.
* \param[in] count Number of items in @p items.
* \return 0 on success, negative error code on failure.
*/
int sof_codec_info_register(const void *owner, const uint32_t *items, uint32_t count);

/**
* \brief Unregister runtime codec audio capabilities for an owner token.
* \param[in] owner Opaque owner token previously passed to sof_codec_info_register().
*/
void sof_codec_info_unregister(const void *owner);
#else
static inline int sof_codec_info_register(const void *owner, const uint32_t *items,
uint32_t count)
{
(void)owner;
(void)items;
(void)count;
return 0;
}

static inline void sof_codec_info_unregister(const void *owner)
{
(void)owner;
}
#endif

#endif /* __SOF_AUDIO_CODEC_INFO_H__ */
10 changes: 10 additions & 0 deletions src/include/sof/lib_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ void lib_manager_get_instance_bss_address(uint32_t instance_id,
*/
int lib_manager_load_library(uint32_t dma_id, uint32_t lib_id, uint32_t type);

/*
* \brief Unload library
*
* param[in] lib_id - library ID to unload (1..LIB_MANAGER_MAX_LIBS - 1)
*
* Unregisters codec capabilities, unloads any cached LLEXT contexts, and frees
* library storage when no module instance is active.
*/
int lib_manager_unload_library(uint32_t lib_id);

struct userspace_context;
/*
* \brief Allocate the module and start the agent if needed
Expand Down
8 changes: 8 additions & 0 deletions src/include/sof/llext_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ uintptr_t llext_manager_allocate_module(const struct comp_ipc_config *ipc_config
int llext_manager_free_module(const uint32_t component_id);

int llext_manager_add_library(uint32_t module_id);
int llext_manager_remove_library(uint32_t module_id);

struct lib_manager_mod_ctx;
struct sof_man_fw_desc;
void llext_manager_register_lib_codecs(const struct lib_manager_mod_ctx *ctx,
const struct sof_man_fw_desc *desc);
void llext_manager_unregister_lib_codecs(const struct lib_manager_mod_ctx *ctx);

int llext_manager_add_domain(const uint32_t component_id, struct k_mem_domain *domain);
int llext_manager_rm_domain(const uint32_t component_id, struct k_mem_domain *domain);
Expand All @@ -39,6 +46,7 @@ bool comp_is_llext(struct comp_dev *comp);
#define llext_manager_allocate_module(ipc_config, ipc_specific_config) 0
#define llext_manager_free_module(component_id) 0
#define llext_manager_add_library(module_id) 0
#define llext_manager_remove_library(module_id) 0
#define llext_manager_add_domain(component_id, domain) 0
#define comp_is_llext(comp) false
#endif
Expand Down
Loading
Loading