Skip to content

Commit f00d8c3

Browse files
committed
audio: iadk: accept module API 4.5.2
Accept IADK module API 4.5.2 in addition to 4.5.0. Extend the detector and system-agent vtables and append the versioned system-service lookup slot without changing earlier slots. This only establishes the 4.5.2 ABI. Services unavailable in the base firmware return an error and clear the interface pointer. Signed-off-by: Gaggery Tsai <gaggery.tsai@intel.com>
1 parent 331b378 commit f00d8c3

10 files changed

Lines changed: 96 additions & 8 deletions

File tree

src/audio/module_adapter/iadk/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ classDiagram
5050

5151
Because the actual module resides in an external binary, it requires a "System Agent" to correctly instantiate the C++ objects during the component's `init` phase.
5252

53+
The adapter accepts IADK API 4.5.0 and 4.5.2 binaries. API 4.5.2
54+
extends the detector interface with `WritePattern()`, adds
55+
`SystemAgentInterface3::GetBssBase()`, and appends a versioned lookup
56+
entry to the system service table. The existing table and vtable slots
57+
keep their API 4.5.0 layout.
58+
5359
1. The OS host driver sends an IPC `INIT_INSTANCE` command for the module.
5460
2. The `system_agent_start()` function intercepts this, invokes the dynamic module's `create_instance` entry point (which invokes a `ModuleFactory`).
5561
3. The `SystemAgent` deduces the pin count (interfaces) and initial pipeline configurations using `ModuleInitialSettingsConcrete`.

src/audio/module_adapter/iadk/system_agent.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
#include <sof/audio/module_adapter/library/native_system_service.h>
2525
#include <sof/audio/module_adapter/library/native_system_agent.h>
2626

27+
struct sof_man_module;
28+
extern "C" const struct sof_man_module *
29+
lib_manager_get_module_manifest(const uint32_t module_id);
30+
extern "C" void
31+
lib_manager_get_instance_bss_address(uint32_t instance_id,
32+
const struct sof_man_module *mod,
33+
void **va_addr, size_t *size);
34+
2735
using namespace intel_adsp;
2836
using namespace intel_adsp::system;
2937
using namespace dsp_fw;
@@ -47,6 +55,7 @@ const APP_TASK_DATA AdspSystemService SystemAgent::system_service_ = {
4755
native_system_service_create_notification,
4856
native_system_service_send_notif_msg,
4957
native_system_service_get_interface,
58+
native_system_service_get_interface_versioned,
5059
};
5160

5261
SystemAgent::SystemAgent(uint32_t module_id,
@@ -79,6 +88,27 @@ void SystemAgent::CheckIn(ProcessingModuleInterface& processing_module,
7988
log_handle = reinterpret_cast<LogHandle*>(log_handle_);
8089
}
8190

91+
void SystemAgent::CheckInDetector(DetectorModuleInterface& processing_module,
92+
ModuleHandle &module_handle,
93+
LogHandle *&log_handle)
94+
{
95+
CheckIn(static_cast<ProcessingModuleInterface&>(processing_module),
96+
module_handle, log_handle);
97+
}
98+
99+
void *SystemAgent::GetBssBase(void)
100+
{
101+
const struct sof_man_module *mod = lib_manager_get_module_manifest(module_id_);
102+
void *base = NULL;
103+
size_t size = 0;
104+
105+
if (!mod)
106+
return NULL;
107+
108+
lib_manager_get_instance_bss_address(instance_id_, mod, &base, &size);
109+
return base;
110+
}
111+
82112
int SystemAgent::CheckIn(ProcessingModuleFactoryInterface& module_factory,
83113
ModulePlaceholder *module_placeholder,
84114
size_t processing_module_size,
@@ -148,4 +178,3 @@ extern "C" void __cxa_pure_virtual() __attribute__((weak));
148178
void __cxa_pure_virtual()
149179
{
150180
}
151-

src/audio/module_adapter/library/native_system_service.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,20 @@ AdspErrorCode native_system_service_send_notif_msg(enum notification_target noti
158158
AdspErrorCode native_system_service_get_interface(enum interface_id id,
159159
struct system_service_iface **iface)
160160
{
161-
if (id < 0)
161+
if (id < 0 || !iface)
162162
return ADSP_INVALID_PARAMETERS;
163-
return ADSP_NO_ERROR;
163+
164+
*iface = NULL;
165+
return ADSP_INVALID_PARAMETERS;
166+
}
167+
168+
AdspErrorCode native_system_service_get_interface_versioned(enum interface_id id,
169+
uint32_t version,
170+
struct system_service_iface **iface)
171+
{
172+
(void)version;
173+
174+
return native_system_service_get_interface(id, iface);
164175
}
165176

166177
const APP_TASK_DATA struct native_system_service native_system_service = {
@@ -171,6 +182,7 @@ const APP_TASK_DATA struct native_system_service native_system_service = {
171182
.vec_memset = native_system_service_vec_memset,
172183
.notification_create = native_system_service_create_notification,
173184
.notification_send = native_system_service_send_notif_msg,
174-
.get_interface = native_system_service_get_interface
185+
.get_interface = native_system_service_get_interface,
186+
.get_interface_versioned = native_system_service_get_interface_versioned
175187
}
176188
};

src/include/module/module/system_service.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ enum interface_id {
7979
INTERFACE_ID_SDCA = 0x1002, /* See SdcaInterface */
8080
INTERFACE_ID_ASYNC_MESSAGE_SERVICE = 0x1003, /* See AsyncMessageInterface */
8181
INTERFACE_ID_AM_SERVICE = 0x1005, /* Reserved for ADSP system */
82-
INTERFACE_ID_KPB_SERVICE = 0x1006 /* See KpbInterface */
82+
INTERFACE_ID_KPB_SERVICE = 0x1006, /* See KpbInterface */
83+
INTERFACE_ID_TIMESTAMPING_SERVICE = 0x1007 /* See TimestampingInterface */
8384
};
8485

8586
/* sub interface definition.
@@ -109,5 +110,8 @@ struct system_service {
109110
uint32_t actual_payload_size);
110111

111112
AdspErrorCode (*get_interface)(enum interface_id id, struct system_service_iface **iface);
113+
114+
AdspErrorCode (*get_interface_versioned)(enum interface_id id, uint32_t version,
115+
struct system_service_iface **iface);
112116
};
113117
#endif /* MODULE_MODULE_SYSTEM_SERVICE_H */

src/include/sof/audio/module_adapter/iadk/api_version.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414

1515
#define IADK_MODULE_API_MAJOR_VERSION 4
1616
#define IADK_MODULE_API_MIDDLE_VERSION 5
17-
#define IADK_MODULE_API_MINOR_VERSION 0
17+
#define IADK_MODULE_API_MINOR_VERSION 2
1818

1919
#define IADK_MODULE_API_CURRENT_VERSION MODULE_API_VERSION_ENCODE(IADK_MODULE_API_MAJOR_VERSION, \
2020
IADK_MODULE_API_MIDDLE_VERSION, IADK_MODULE_API_MINOR_VERSION)
2121

22+
/* API 4.5.0 remains compatible with the extended interface tables. */
23+
#define IADK_MODULE_API_VERSION_4_5_0 MODULE_API_VERSION_ENCODE(4, 5, 0)
24+
2225
/* Defines the size of the space reserved within ModuleHandle for SOF to store its private data.
2326
* This size comes from the IADK header files and must match the IADK API version.
2427
* Please do not modify this value!

src/include/sof/audio/module_adapter/iadk/processing_module_interface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ namespace intel_adsp
399399
virtual void OnStreamState(uint64_t counter,
400400
uint32_t stream_index,
401401
State state) = 0;
402+
403+
/*! Write a pattern when an output stream resumes processing. */
404+
virtual void WritePattern(uint16_t stream_index,
405+
OutputStreamBuffer *output_buffer) = 0;
402406
};
403407
} /*namespace intel_adsp */
404408

src/include/sof/audio/module_adapter/iadk/system_agent.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace system
2121
* A SystemAgent can only be delivered by the ADSP System.
2222
* Once registered, a ModuleHandle instance can be handled by the ADSP System.
2323
*/
24-
class SystemAgent : public intel_adsp::SystemAgentInterface
24+
class SystemAgent : public intel_adsp::SystemAgentInterface3
2525
{
2626
public:
2727
SystemAgent(uint32_t module_id,
@@ -34,6 +34,15 @@ namespace system
3434
intel_adsp::ModuleHandle & module_handle,
3535
intel_adsp::LogHandle * &log_handle) /*override*/;
3636

37+
/*! \brief Registers a detector module. */
38+
virtual void CheckInDetector(
39+
DetectorModuleInterface & processing_module,
40+
ModuleHandle & module_handle,
41+
LogHandle * &log_handle) /*override*/;
42+
43+
/*! \brief Returns the BSS base for the current module instance. */
44+
virtual void *GetBssBase(void) /*override*/;
45+
3746
/*! \return a value part of error code list defined within the adsp_error.h*/
3847
virtual int CheckIn(intel_adsp::ProcessingModuleFactoryInterface & module_factory,
3948
intel_adsp::ModulePlaceholder * module_placeholder,

src/include/sof/audio/module_adapter/iadk/system_agent_interface.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ namespace internal
134134
) = 0;
135135
};
136136

137+
class SystemAgentInterface3 : public SystemAgentInterface2
138+
{
139+
public:
140+
141+
/*! \brief Gets the BSS base for the current module instance. */
142+
virtual void *GetBssBase(void) = 0;
143+
};
144+
137145
} /* namespace intel_adsp */
138146

139147
#endif /* _ADSP_SYSTEM_AGENT_H_ */

src/include/sof/audio/module_adapter/library/native_system_service.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ AdspErrorCode native_system_service_send_notif_msg(enum notification_target noti
4242
AdspErrorCode native_system_service_get_interface(enum interface_id id,
4343
struct system_service_iface **iface);
4444

45+
/**
46+
* \brief Retrieve a versioned system service interface.
47+
*
48+
* \param id Service interface identifier.
49+
* \param version Requested interface version.
50+
* \param iface Location for the returned interface pointer.
51+
* \return ADSP_INVALID_PARAMETERS if the interface is unavailable.
52+
*/
53+
AdspErrorCode native_system_service_get_interface_versioned(enum interface_id id,
54+
uint32_t version,
55+
struct system_service_iface **iface);
56+
4557
extern const struct native_system_service native_system_service;
4658

4759
#ifdef __cplusplus

src/library_manager/lib_manager.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,8 @@ static enum buildinfo_mod_type lib_manager_get_module_type(const struct sof_man_
628628
/* Check if module is IADK */
629629
if (IS_ENABLED(CONFIG_INTEL_MODULES) &&
630630
build_info->format == IADK_MODULE_API_BUILD_INFO_FORMAT &&
631-
build_info->api_version_number.full == IADK_MODULE_API_CURRENT_VERSION) {
631+
(build_info->api_version_number.full == IADK_MODULE_API_CURRENT_VERSION ||
632+
build_info->api_version_number.full == IADK_MODULE_API_VERSION_4_5_0)) {
632633
return MOD_TYPE_IADK;
633634
} else {
634635
/* Check if module is NOT native */

0 commit comments

Comments
 (0)