Skip to content

Commit

Permalink
Merge branch 'main' into topic/upstream/cionly/zephyr_pr/75665
Browse files Browse the repository at this point in the history
Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif authored Aug 5, 2024
2 parents c1eeab3 + 7bd1953 commit aafcbbf
Show file tree
Hide file tree
Showing 34 changed files with 322 additions and 504 deletions.
4 changes: 2 additions & 2 deletions lmdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
To build dummy loadable library execute:

cd libraries/dummy
cmake -B build -G <Ninja/Makefile> -DRIMAGE_INSTALL_DIR="path/where/rimage/executable/is" -DSNIGNING_KEY="path/to/key"
cmake -B build -G <Ninja/Makefile> -DRIMAGE_INSTALL_DIR="path/where/rimage/executable/is" -DSIGNING_KEY="path/to/key"
cd --build build


Expand All @@ -14,4 +14,4 @@ signing key for rimage. If RIMAGE_INSTALL_DIR is not provided, rimage will be se
where SOF project installs it. Dummy module sets up toolchain file in the project file.
However, in your library you can select toolchain file in the configure step command:

cmake -B build -G <Ninja/Makefile> --toolchain "../../cmake/xtensa-toolchain.cmake" -DSNIGNING_KEY="path/to/key"
cmake -B build -G <Ninja/Makefile> --toolchain "../../cmake/xtensa-toolchain.cmake" -DSIGNING_KEY="path/to/key"
4 changes: 2 additions & 2 deletions lmdk/cmake/ldscripts/data_linker_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SECTIONS {
} >HPSRAM_seg : rodata_phdr

/* Module manifest is here */
.module 0 : {
.module : {
KEEP(*(.module))
}
} >HPSRAM_seg : rodata_phdr
}
5 changes: 4 additions & 1 deletion lmdk/modules/smart_amp_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ target_compile_definitions(smart_amp_test PRIVATE
CONFIG_IPC_MAJOR_4=1
)

target_include_directories(smart_amp_test PRIVATE "${SOF_BASE}/src/include")
target_include_directories(smart_amp_test PRIVATE
"${SOF_BASE}/src/include"
"${SOF_BASE}/posix/include"
)
10 changes: 5 additions & 5 deletions posix/include/sof/lib/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,14 @@ int dma_buffer_copy_to(struct comp_buffer __sparse_cache *source,
dma_process_func process, uint32_t sink_bytes, uint32_t chmap);

/*
* Used when copying DMA buffer bytes into multiple sink buffers, one at a time using the provided
* Used when copying stream audio into multiple sink buffers, one at a time using the provided
* conversion function. DMA buffer consume should be performed after the data has been copied
* to all sinks.
*/
int dma_buffer_copy_from_no_consume(struct comp_buffer __sparse_cache *source,
struct comp_buffer __sparse_cache *sink,
dma_process_func process,
uint32_t source_bytes, uint32_t chmap);
int stream_copy_from_no_consume(struct comp_buffer __sparse_cache *source,
struct comp_buffer __sparse_cache *sink,
dma_process_func process,
uint32_t source_bytes, uint32_t chmap);

/* generic DMA DSP <-> Host copier */

Expand Down
73 changes: 67 additions & 6 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,56 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
}

if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
#if CONFIG_IPC_MAJOR_4
struct list_item *sink_list;
/*
* copy from local buffer to all sinks that are not gateway buffers
* using the right PCM converter function.
*/
list_for_item(sink_list, &dev->bsink_list) {
struct comp_dev *sink_dev;
struct comp_buffer *sink;
int j;

sink = container_of(sink_list, struct comp_buffer, source_list);

if (sink == dd->dma_buffer)
continue;

sink_dev = sink->sink;

j = IPC4_SRC_QUEUE_ID(buf_get_id(sink));

if (j >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) {
comp_err(dev, "Sink queue ID: %d >= max output pin count: %d\n",
j, IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT);
ret = -EINVAL;
continue;
}

if (!converter[j]) {
comp_err(dev, "No PCM converter for sink queue %d\n", j);
ret = -EINVAL;
continue;
}

if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
sink->hw_params_configured) {
ret = stream_copy_from_no_consume(dd->local_buffer, sink,
converter[j], bytes, dd->chmap);
}
}
#endif
ret = dma_buffer_copy_to(dd->local_buffer, dd->dma_buffer,
dd->process, bytes, dd->chmap);
} else {
audio_stream_invalidate(&dd->dma_buffer->stream, bytes);
/*
* The PCM converter functions used during DMA buffer copy can never fail,
* so no need to check the return value of dma_buffer_copy_from_no_consume().
* so no need to check the return value of stream_copy_from_no_consume().
*/
ret = dma_buffer_copy_from_no_consume(dd->dma_buffer, dd->local_buffer,
dd->process, bytes, dd->chmap);
ret = stream_copy_from_no_consume(dd->dma_buffer, dd->local_buffer,
dd->process, bytes, dd->chmap);
#if CONFIG_IPC_MAJOR_4
struct list_item *sink_list;
/* Skip in case of endpoint DAI devices created by the copier */
Expand Down Expand Up @@ -316,9 +356,9 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,

if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
sink->hw_params_configured)
ret = dma_buffer_copy_from_no_consume(dd->dma_buffer,
sink, converter[j],
bytes, dd->chmap);
ret = stream_copy_from_no_consume(dd->dma_buffer,
sink, converter[j],
bytes, dd->chmap);
}
}
#endif
Expand Down Expand Up @@ -1553,6 +1593,27 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
src_frames = audio_stream_get_avail_frames(&dd->local_buffer->stream);
sink_frames = free_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);
frames = MIN(src_frames, sink_frames);

struct list_item *sink_list;
/*
* In the case of playback DAI's with multiple sink buffers, compute the
* minimum number of frames based on the DMA avail_bytes and the free
* samples in all active sink buffers.
*/
list_for_item(sink_list, &dev->bsink_list) {
struct comp_dev *sink_dev;
struct comp_buffer *sink;

sink = container_of(sink_list, struct comp_buffer, source_list);
sink_dev = sink->sink;

if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
sink->hw_params_configured) {
sink_frames =
audio_stream_get_free_frames(&sink->stream);
frames = MIN(frames, sink_frames);
}
}
} else {
struct list_item *sink_list;

Expand Down
4 changes: 4 additions & 0 deletions src/audio/module_adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD)
sof_add_static_library(xa_mp3_dec ${CONFIG_CADENCE_CODEC_MP3_DEC_LIB})
endif()

if(CONFIG_CADENCE_CODEC_MP3_ENC)
sof_add_static_library(xa_mp3_enc ${CONFIG_CADENCE_CODEC_MP3_ENC_LIB})
endif()

if(CONFIG_CADENCE_CODEC_SBC_DEC)
sof_add_static_library(xa_sbc_dec ${CONFIG_CADENCE_CODEC_SBC_DEC_LIB})
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <adsp_stddef.h>
#include <module_initial_settings_concrete.h>
#include <logger.h>

extern "C" {
int memcpy_s(void * dst, size_t maxlen, const void * src, size_t len);
Expand Down
3 changes: 1 addition & 2 deletions src/audio/module_adapter/iadk/system_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <rtos/string.h>
#include <utilities/array.h>
#include <module/iadk/adsp_error_code.h>
#include <logger.h>
#include <native_system_service.h>
#include <system_agent_interface.h>
#include <module_initial_settings_concrete.h>
Expand Down Expand Up @@ -62,7 +61,7 @@ namespace system
{

/* Structure storing handles to system service operations */
AdspSystemService SystemAgent::system_service_ = {
const AdspSystemService SystemAgent::system_service_ = {
native_system_service_log_message,
native_system_service_safe_memcpy,
native_system_service_safe_memmove,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/library/native_system_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ AdspErrorCode native_system_service_get_interface(adsp_iface_id id, system_servi
return ADSP_NO_ERROR;
}

struct native_system_service_api native_system_service = {
const struct native_system_service_api native_system_service = {
.log_message = native_system_service_log_message,
.safe_memcpy = native_system_service_safe_memcpy,
.safe_memmove = native_system_service_safe_memmove,
Expand Down
39 changes: 18 additions & 21 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u
comp_info(dev, "multiband_drc_init_coef(), initializing %i-way crossover",
config->num_bands);

/* Crossover: determine the split function */
cd->crossover_split = crossover_find_split_func(config->num_bands);
if (!cd->crossover_split) {
comp_err(dev, "multiband_drc_init_coef(), No crossover_split for band count(%i)",
config->num_bands);
return -EINVAL;
}

/* Crossover: collect the coef array and assign it to every channel */
crossover = config->crossover_coef;
for (ch = 0; ch < nch; ch++) {
Expand Down Expand Up @@ -328,7 +336,10 @@ static int multiband_drc_process(struct processing_module *mod,
}
}

cd->multiband_drc_func(mod, source, sink, frames);
if (cd->process_enabled)
cd->multiband_drc_func(mod, source, sink, frames);
else
multiband_drc_default_pass(mod, source, sink, frames);

/* calc new free and available */
module_update_buffer_position(&input_buffers[0], &output_buffers[0], frames);
Expand Down Expand Up @@ -364,32 +375,18 @@ static int multiband_drc_prepare(struct processing_module *mod,
comp_dbg(dev, "multiband_drc_prepare(), source_format=%d, sink_format=%d",
cd->source_format, cd->source_format);
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
if (cd->config && cd->process_enabled) {
if (cd->config) {
ret = multiband_drc_setup(mod, channels, rate);
if (ret < 0) {
comp_err(dev, "multiband_drc_prepare() error: multiband_drc_setup failed.");
return ret;
}
}

cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func");
return -EINVAL;
}

cd->crossover_split = crossover_find_split_func(cd->config->num_bands);
if (!cd->crossover_split) {
comp_err(dev, "multiband_drc_prepare(), No crossover_split for band num %i",
cd->config->num_bands);
return -EINVAL;
}
} else {
comp_info(dev, "multiband_drc_prepare(), DRC is in passthrough mode");
cd->multiband_drc_func = multiband_drc_find_proc_func_pass(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func passthrough");
return -EINVAL;
}
cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func");
return -EINVAL;
}

return ret;
Expand Down
5 changes: 5 additions & 0 deletions src/audio/multiband_drc/multiband_drc.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap[];
extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap_pass[];
extern const size_t multiband_drc_proc_fncount;

void multiband_drc_default_pass(const struct processing_module *mod,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames);

/**
* \brief Returns Multiband DRC processing function.
*/
Expand Down
8 changes: 4 additions & 4 deletions src/audio/multiband_drc/multiband_drc_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "multiband_drc.h"
#include "../drc/drc_algorithm.h"

static void multiband_drc_default_pass(const struct processing_module *mod,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
void multiband_drc_default_pass(const struct processing_module *mod,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
{
audio_stream_copy(source, 0, sink, 0, audio_stream_get_channels(source) * frames);
}
Expand Down
14 changes: 7 additions & 7 deletions src/audio/tdfb/tdfb_direction.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ static int16_t max_mic_distance(struct tdfb_comp_data *cd)

/* Max lag based on largest array dimension. Microphone coordinates are Q4.12 meters */
for (i = 0; i < cd->config->num_mic_locations; i++) {
for (j = 0; i < cd->config->num_mic_locations; i++) {
if (j == i)
continue;

/* Calculate distances between all possible microphone pairs to
* find the maximum distance
*/
for (j = i + 1; j < cd->config->num_mic_locations; j++) {
dx = cd->mic_locations[i].x - cd->mic_locations[j].x;
dy = cd->mic_locations[i].y - cd->mic_locations[j].y;
dz = cd->mic_locations[i].z - cd->mic_locations[j].z;
Expand Down Expand Up @@ -157,9 +157,9 @@ static bool line_array_mode_check(struct tdfb_comp_data *cd)

/* Cross product of vectors AB and AC is (0, 0, 0) if they are co-linear.
* Form vector AB(a,b,c) from x(i+1) - x(i), y(i+1) - y(i), z(i+1) - z(i)
* Form vector AC(d,e,f) from x(i+2) - x(i), y(i+2) - y(1), z(i+2) - z(i)
* Form vector AC(d,e,f) from x(i+2) - x(i), y(i+2) - y(i), z(i+2) - z(i)
*/
for (i = 0; i < num_mic_locations - 3; i++) {
for (i = 0; i < num_mic_locations - 2; i++) {
a = cd->mic_locations[i + 1].x - cd->mic_locations[i].x;
b = cd->mic_locations[i + 1].y - cd->mic_locations[i].y;
c = cd->mic_locations[i + 1].z - cd->mic_locations[i].z;
Expand Down Expand Up @@ -282,9 +282,9 @@ static void level_update(struct tdfb_comp_data *cd, int frames, int ch_count, in
/* Calculate mean square level */
for (n = 0; n < frames; n++) {
s = *p;
tmp += ((int32_t)s * s);
p += ch_count;
tdfb_cinc_s16(&p, cd->direction.d_end, cd->direction.d_size);
tmp += ((int64_t)s * s);
}

/* Calculate mean square power */
Expand Down
6 changes: 3 additions & 3 deletions src/include/module/module/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Adrian Warecki <[email protected]>
*/

#ifndef __MODULE_MODULE_GENERIC__
#define __MODULE_MODULE_GENERIC__
#ifndef __MODULE_MODULE_BASE__
#define __MODULE_MODULE_BASE__

#include <stdint.h>
#include <stddef.h>
Expand Down Expand Up @@ -180,4 +180,4 @@ struct processing_module {
#endif /* SOF_MODULE_PRIVATE */
};

#endif /* __MODULE_MODULE_GENERIC__ */
#endif /* __MODULE_MODULE_BASE__ */
Loading

0 comments on commit aafcbbf

Please sign in to comment.