Skip to content
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

sof_api: lmdk: Extraction of api headers for loadable modules #8365

Merged
merged 10 commits into from
Nov 24, 2023
9 changes: 9 additions & 0 deletions lmdk/cmake/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ endif()

include(${CMAKE_CURRENT_LIST_DIR}/config.cmake)

# Build common module functions from sof to a static library
add_library(sof STATIC)
target_include_directories(sof PRIVATE "${SOF_BASE}/src/include")
add_subdirectory("${SOF_BASE}/src/module" module_api)

foreach(MODULE ${MODULES_LIST})
add_executable(${MODULE})
add_subdirectory(${LMDK_BASE}/modules/${MODULE} ${MODULE}_module)
Expand All @@ -19,6 +24,7 @@ foreach(MODULE ${MODULES_LIST})
target_include_directories(${MODULE} PRIVATE
"${LMDK_BASE}/include"
"${RIMAGE_INCLUDE_DIR}"
"${SOF_BASE}/src/include/module"
)

# generate linker script
Expand All @@ -35,6 +41,9 @@ foreach(MODULE ${MODULES_LIST})
-P ${CMAKE_CURRENT_LIST_DIR}/ldscripts.cmake
)

# Link module with sof common module functions
target_link_libraries(${MODULE} sof)

target_link_options(${MODULE} PRIVATE
"-nostartfiles"
"-Wl,--no-undefined" "-Wl,--unresolved-symbols=report-all" "-Wl,--error-unresolved-symbols"
Expand Down
19 changes: 19 additions & 0 deletions lmdk/cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@ cmake_path(ABSOLUTE_PATH SOF_BASE NORMALIZE)

set(RIMAGE_INCLUDE_DIR ${SOF_BASE}/tools/rimage/src/include)
cmake_path(ABSOLUTE_PATH RIMAGE_INCLUDE_DIR NORMALIZE)

# Adds sources to target like target_sources, but assumes that
# paths are relative to subdirectory.
# Works like:
# Cmake >= 3.13:
# target_sources(<target> PRIVATE <sources>)
# Cmake < 3.13:
# target_sources(<target> PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/<sources>)
function(add_local_sources target)
foreach(arg ${ARGN})
if(IS_ABSOLUTE ${arg})
set(path ${arg})
else()
set(path ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
endif()

target_sources(${target} PRIVATE ${path})
endforeach()
endfunction()
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ add_subdirectory(ipc)
add_subdirectory(audio)
add_subdirectory(lib)
add_subdirectory(math)
add_subdirectory(module)

if(CONFIG_SAMPLES)
add_subdirectory(samples)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/iadk/system_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <stdint.h>
#include <rtos/string.h>
#include <utilities/array.h>
#include <adsp_error_code.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so now we have sof_api and iadk ?

Should not IADK go to sof_api as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the difference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cujomalainey IADK is an Intel C++ wrapper/extension to the base sof C module API that aligns with modules used on Windows today.

#include <module/iadk/adsp_error_code.h>
#include <logger.h>
#include <native_system_service.h>
#include <system_agent_interface.h>
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <native_system_agent.h>
#include <sof/lib_manager.h>
#include <sof/audio/module_adapter/module/module_interface.h>
#include <module_api_ver.h>
#include <module/module/api_ver.h>

/* Intel module adapter is an extension to SOF module adapter component that allows to integrate
* modules developed under IADK (Intel Audio Development Kit) Framework. IADK modules uses uniform
Expand Down
167 changes: 5 additions & 162 deletions src/audio/sink_api_helper.c
Original file line number Diff line number Diff line change
@@ -1,61 +1,20 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2023 Intel Corporation. All rights reserved.
//
/*
* Copyright(c) 2023 Intel Corporation. All rights reserved.
*/

#include <sof/audio/sink_api.h>
#include <sof/audio/sink_api_implementation.h>
#include <sof/audio/audio_stream.h>

/* This file contains private sink API functions intended for use only by the sof. */

void sink_init(struct sof_sink *sink, const struct sink_ops *ops,
struct sof_audio_stream_params *audio_stream_params)
{
sink->ops = ops;
sink->audio_stream_params = audio_stream_params;
}

size_t sink_get_free_size(struct sof_sink *sink)
{
return sink->ops->get_free_size(sink);
}

int sink_get_buffer(struct sof_sink *sink, size_t req_size,
void **data_ptr, void **buffer_start, size_t *buffer_size)
{
int ret;

if (sink->requested_write_frag_size)
return -EBUSY;

ret = sink->ops->get_buffer(sink, req_size, data_ptr,
buffer_start, buffer_size);

if (!ret)
sink->requested_write_frag_size = req_size;
return ret;
}

int sink_commit_buffer(struct sof_sink *sink, size_t commit_size)
{
int ret;

/* check if there was a buffer obtained for writing by sink_get_buffer */
if (!sink->requested_write_frag_size)
return -ENODATA;

/* limit size of data to be committed to previously obtained size */
if (commit_size > sink->requested_write_frag_size)
commit_size = sink->requested_write_frag_size;

ret = sink->ops->commit_buffer(sink, commit_size);

if (!ret)
sink->requested_write_frag_size = 0;

sink->num_of_bytes_processed += commit_size;
return ret;
}

size_t sink_get_num_of_processed_bytes(struct sof_sink *sink)
{
return sink->num_of_bytes_processed;
Expand All @@ -66,128 +25,12 @@ void sink_reset_num_of_processed_bytes(struct sof_sink *sink)
sink->num_of_bytes_processed = 0;
}

enum sof_ipc_frame sink_get_frm_fmt(struct sof_sink *sink)
{
return sink->audio_stream_params->frame_fmt;
}

enum sof_ipc_frame sink_get_valid_fmt(struct sof_sink *sink)
{
return sink->audio_stream_params->valid_sample_fmt;
}

uint32_t sink_get_rate(struct sof_sink *sink)
{
return sink->audio_stream_params->rate;
}

uint32_t sink_get_channels(struct sof_sink *sink)
{
return sink->audio_stream_params->channels;
}

uint32_t sink_get_buffer_fmt(struct sof_sink *sink)
{
return sink->audio_stream_params->buffer_fmt;
}

bool sink_get_overrun(struct sof_sink *sink)
{
return sink->audio_stream_params->overrun_permitted;
}

int sink_set_frm_fmt(struct sof_sink *sink, enum sof_ipc_frame frame_fmt)
{
sink->audio_stream_params->frame_fmt = frame_fmt;

/* notify the implementation */
if (sink->ops->on_audio_format_set)
return sink->ops->on_audio_format_set(sink);
return 0;
}

int sink_set_valid_fmt(struct sof_sink *sink,
enum sof_ipc_frame valid_sample_fmt)
{
sink->audio_stream_params->valid_sample_fmt = valid_sample_fmt;
if (sink->ops->on_audio_format_set)
return sink->ops->on_audio_format_set(sink);
return 0;
}

int sink_set_rate(struct sof_sink *sink, unsigned int rate)
{
sink->audio_stream_params->rate = rate;
if (sink->ops->on_audio_format_set)
return sink->ops->on_audio_format_set(sink);
return 0;
}

int sink_set_channels(struct sof_sink *sink, unsigned int channels)
{
sink->audio_stream_params->channels = channels;
if (sink->ops->on_audio_format_set)
return sink->ops->on_audio_format_set(sink);
return 0;
}

int sink_set_buffer_fmt(struct sof_sink *sink, uint32_t buffer_fmt)
{
sink->audio_stream_params->buffer_fmt = buffer_fmt;
if (sink->ops->on_audio_format_set)
return sink->ops->on_audio_format_set(sink);
return 0;
}

int sink_set_overrun(struct sof_sink *sink, bool overrun_permitted)
{
sink->audio_stream_params->overrun_permitted = overrun_permitted;
if (sink->ops->on_audio_format_set)
return sink->ops->on_audio_format_set(sink);
return 0;
}

size_t sink_get_frame_bytes(struct sof_sink *sink)
{
return get_frame_bytes(sink_get_frm_fmt(sink),
sink_get_channels(sink));
}

size_t sink_get_free_frames(struct sof_sink *sink)
{
return sink_get_free_size(sink) /
sink_get_frame_bytes(sink);
}

int sink_set_params(struct sof_sink *sink,
struct sof_ipc_stream_params *params, bool force_update)
{
if (sink->ops->audio_set_ipc_params)
return sink->ops->audio_set_ipc_params(sink, params, force_update);
return 0;
}

int sink_set_alignment_constants(struct sof_sink *sink,
const uint32_t byte_align,
const uint32_t frame_align_req)
{
if (sink->ops->set_alignment_constants)
return sink->ops->set_alignment_constants(sink, byte_align, frame_align_req);
return 0;
}

void sink_set_min_free_space(struct sof_sink *sink, size_t min_free_space)
{
sink->min_free_space = min_free_space;
}

size_t sink_get_min_free_space(struct sof_sink *sink)
{
return sink->min_free_space;
}

uint32_t sink_get_id(struct sof_sink *sink)
{
return sink->audio_stream_params->id;
}

Loading
Loading