Repository navigation
audio: iadk: implement KPB service #11307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
serhiy-katsyuba-intel
wants to merge
3
commits into
thesofproject:main
Choose a base branch
from
serhiy-katsyuba-intel:kpb_iface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| // | ||
| // Copyright 2026 Intel Corporation. All rights reserved. | ||
|
|
||
| #include <rtos/userspace_helper.h> | ||
| #include <sof/audio/module_adapter/iadk/kpb_interface.h> | ||
| #include <sof/audio/module_adapter/library/kpb_service.h> | ||
| #include <sof/audio/module_adapter/library/native_system_service.h> | ||
|
|
||
| namespace intel_adsp | ||
| { | ||
|
|
||
| struct KpbToken { | ||
|
serhiy-katsyuba-intel marked this conversation as resolved.
|
||
| const ModuleHandle *owner; | ||
| void *kpb_client; | ||
| }; | ||
|
|
||
| /** | ||
| * \class KpbServiceV1 | ||
| * \brief SOF implementation of the KPB service v1 interface. | ||
| */ | ||
| class KpbServiceV1 final : public KpbInterface { | ||
| public: | ||
| ErrorCode::Type RegisterKpbClient(const ModuleHandle& module_handle, KpbToken& token, | ||
| size_t current_history_depth, size_t max_history_depth, | ||
| uint32_t output_pin) const override | ||
| { | ||
| struct kpb_service_client *client; | ||
| AdspErrorCode error = kpb_service_register_client( | ||
| current_history_depth, | ||
| max_history_depth, | ||
| output_pin, &client); | ||
|
serhiy-katsyuba-intel marked this conversation as resolved.
|
||
|
|
||
| if (error == ADSP_NO_ERROR) { | ||
| token.owner = &module_handle; | ||
| token.kpb_client = client; | ||
| } | ||
|
|
||
| return error; | ||
| } | ||
|
|
||
| ErrorCode::Type SignalDetection(KpbToken& token, void* data) const override | ||
| { | ||
| if (!token.owner || !token.kpb_client || !data) | ||
| return ADSP_INVALID_PARAMETERS; | ||
|
|
||
| return kpb_service_signal_detection( | ||
| reinterpret_cast<struct kpb_service_client *>(token.kpb_client), | ||
| *static_cast<uint32_t *>(data)); | ||
| } | ||
|
|
||
| ErrorCode::Type SignalVoiceDetection(KpbToken&, void*) const override | ||
| { | ||
| return ADSP_NO_ERROR; | ||
| } | ||
|
|
||
| ErrorCode::Type SignalSilenceDetection(KpbToken&, void*) const override | ||
| { | ||
| return ADSP_NO_ERROR; | ||
| } | ||
|
|
||
| ErrorCode::Type UnregisterKpbClient(KpbToken& token) const override | ||
| { | ||
| if (!token.kpb_client) { | ||
| token.owner = NULL; | ||
| return ADSP_NO_ERROR; | ||
| } | ||
|
|
||
| AdspErrorCode error = kpb_service_unregister_client( | ||
| reinterpret_cast<struct kpb_service_client *>(token.kpb_client)); | ||
|
|
||
| if (error == ADSP_NO_ERROR) { | ||
| token.owner = NULL; | ||
| token.kpb_client = NULL; | ||
| } | ||
|
|
||
| return error; | ||
| } | ||
|
|
||
| ErrorCode::Type RegisterWovProducer(const ModuleHandle&) const override | ||
| { | ||
| return ADSP_NO_ERROR; | ||
| } | ||
|
|
||
| ErrorCode::Type RegisterKpbProducer(const ModuleHandle&) const override | ||
| { | ||
| return ADSP_NO_ERROR; | ||
| } | ||
|
|
||
| ErrorCode::Type RequestWovConsumer(const ModuleHandle&) const override | ||
| { | ||
| return ADSP_NO_ERROR; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * \class KpbServiceV2 | ||
| * \brief KPB service v2 implemented as the compatible subset of v1. | ||
| */ | ||
| class KpbServiceV2 final : public KpbInterfaceV2 { | ||
| public: | ||
| ErrorCode::Type RegisterKpbClient(const ModuleHandle& module_handle, KpbToken& token, | ||
| size_t current_history_depth, size_t max_history_depth, | ||
| uint32_t output_pin) const override | ||
| { | ||
| return v1_.RegisterKpbClient(module_handle, token, current_history_depth, | ||
| max_history_depth, output_pin); | ||
| } | ||
|
|
||
| ErrorCode::Type SignalDetection(KpbToken& token, void* data) const override | ||
| { | ||
| return v1_.SignalDetection(token, data); | ||
| } | ||
|
|
||
| ErrorCode::Type UnregisterKpbClient(KpbToken& token) const override | ||
| { | ||
| return v1_.UnregisterKpbClient(token); | ||
| } | ||
|
|
||
| ErrorCode::Type RegisterKpbProducer(const ModuleHandle& module_handle) const override | ||
| { | ||
| return v1_.RegisterKpbProducer(module_handle); | ||
| } | ||
|
|
||
| private: | ||
| KpbServiceV1 v1_; | ||
| }; | ||
|
|
||
| static APP_TASK_DATA KpbServiceV1 kpb_service_v1; | ||
| static APP_TASK_DATA KpbServiceV2 kpb_service_v2; | ||
|
|
||
| } /* namespace intel_adsp */ | ||
|
|
||
| extern "C" struct system_service_iface *native_kpb_service_get_interface_v1(void) | ||
| { | ||
| return reinterpret_cast<struct system_service_iface *>( | ||
| &intel_adsp::kpb_service_v1); | ||
| } | ||
|
|
||
| extern "C" struct system_service_iface *native_kpb_service_get_interface_v2(void) | ||
| { | ||
| return reinterpret_cast<struct system_service_iface *>( | ||
| &intel_adsp::kpb_service_v2); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.