Skip to content

Commit

Permalink
loadable: adding ifndef for building loadable
Browse files Browse the repository at this point in the history
  • Loading branch information
pjdobrowolski committed Dec 21, 2023
1 parent 21e3792 commit 27a5d7e
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 265 deletions.
26 changes: 16 additions & 10 deletions src/audio/up_down_mixer/up_down_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
#include "up_down_mixer_coef.h"
#include "up_down_mixer.h"

#include <errno.h>
#include <sof/audio/module_adapter/library/native_system_service.h>
#include <stdlib.h>
#include <stdint.h>

//LOG_MODULE_REGISTER(up_down_mixer, CONFIG_SOF_LOG_LEVEL);
//
///* these ids aligns windows driver requirement to support windows driver */
Expand All @@ -29,7 +34,8 @@
#define comp_err(...)
#define comp_dbg(...)

static const struct native_system_agent* native_sys_agent;
static struct native_system_service_api* system_service;
uint32_t heap_mem[2048] __attribute__((section(".heap_mem"))) __attribute__((aligned(4096)));

int32_t custom_coeffs[UP_DOWN_MIX_COEFFS_LENGTH];

Expand All @@ -43,7 +49,7 @@ static int set_downmix_coefficients(struct processing_module *mod,
int ret;

if (cd->downmix_coefficients) {
ret = memcpy_s(&custom_coeffs, sizeof(custom_coeffs), downmix_coefficients,
ret = system_service->safe_memcpy(&custom_coeffs, sizeof(custom_coeffs), downmix_coefficients,
sizeof(int32_t) * UP_DOWN_MIX_COEFFS_LENGTH);

if (ret < 0)
Expand Down Expand Up @@ -321,9 +327,9 @@ static int up_down_mixer_free(struct processing_module *mod)
{
struct up_down_mixer_data *cd = module_get_private_data(mod);

rfree(cd->buf_in);
rfree(cd->buf_out);
rfree(cd);
free(cd->buf_in);
free(cd->buf_out);
free(cd);

return 0;
}
Expand All @@ -337,16 +343,16 @@ static int up_down_mixer_init(struct processing_module *mod)
struct up_down_mixer_data *cd;
int ret;

cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
cd = malloc(sizeof(struct up_down_mixer_data));
if (!cd) {
comp_free(dev);
//comp_free(dev);
return -ENOMEM;
}

mod_data->private = cd;

cd->buf_in = rballoc(0, SOF_MEM_CAPS_RAM, mod->priv.cfg.base_cfg.ibs);
cd->buf_out = rballoc(0, SOF_MEM_CAPS_RAM, mod->priv.cfg.base_cfg.obs);
cd->buf_in = malloc(mod->priv.cfg.base_cfg.ibs);
cd->buf_out = malloc(mod->priv.cfg.base_cfg.obs);
if (!cd->buf_in || !cd->buf_out) {
ret = -ENOMEM;
goto err;
Expand Down Expand Up @@ -447,7 +453,7 @@ DECLARE_LOADABLE_MODULE_API_VERSION(udm);

static void* entry_point(void* mod_cfg, void* parent_ppl, void** mod_ptr)
{
native_sys_agent = *(const struct native_system_agent**)mod_ptr;
system_service = *(const struct native_system_agent**)mod_ptr;

return &up_down_mixer_interface;
}
Expand Down
2 changes: 2 additions & 0 deletions src/include/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ struct sof_ipc_comp {
/*
* SOF memory capabilities, add new ones at the end
*/
#define BIT(b) (1UL << (b))

#define SOF_MEM_CAPS_RAM BIT(0)
#define SOF_MEM_CAPS_ROM BIT(1)
#define SOF_MEM_CAPS_EXT BIT(2) /**< external */
Expand Down
2 changes: 2 additions & 0 deletions src/include/sof/audio/audio_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
#include <sof/compiler_attributes.h>
#include <rtos/panic.h>
#include <sof/math/numbers.h>
#ifndef MODULE_PRIVAT
#include <rtos/alloc.h>
#include <rtos/cache.h>
#endif
#include <ipc/stream.h>
#include <ipc4/base-config.h>
#include <module/audio/audio_stream.h>
Expand Down
4 changes: 2 additions & 2 deletions src/include/sof/audio/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#ifndef __SOF_AUDIO_BUFFER_H__
#define __SOF_AUDIO_BUFFER_H__

#ifndef MODULE_PRIVAT
#include <sof/audio/audio_stream.h>
#include <sof/audio/pipeline.h>
#include <sof/math/numbers.h>
Expand All @@ -26,7 +26,7 @@
#include <ipc/topology.h>
#include <user/trace.h>
#include <sof/audio/format.h>

#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Expand Down
44 changes: 41 additions & 3 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,57 @@
#include <sof/lib/dai.h>
#include <sof/schedule/schedule.h>
#include <ipc/control.h>
#else
#include <sof/ipc/topology.h>
#endif
#include <kernel/abi.h>

#include <stdbool.h>
#include <stdint.h>
#include <limits.h>

#include <sof/list.h>
struct comp_dev;
struct sof_ipc_stream_posn;
struct dai_hw_params;
struct timestamp_data;
struct dai_ts_data;

/* types of component */
enum sof_comp_type {
SOF_COMP_NONE = 0,
SOF_COMP_HOST,
SOF_COMP_DAI,
SOF_COMP_SG_HOST, /**< scatter gather variant */
SOF_COMP_SG_DAI, /**< scatter gather variant */
SOF_COMP_VOLUME,
SOF_COMP_MIXER,
SOF_COMP_MUX,
SOF_COMP_SRC,
SOF_COMP_DEPRECATED0, /* Formerly SOF_COMP_SPLITTER */
SOF_COMP_TONE,
SOF_COMP_DEPRECATED1, /* Formerly SOF_COMP_SWITCH */
SOF_COMP_BUFFER,
SOF_COMP_EQ_IIR,
SOF_COMP_EQ_FIR,
SOF_COMP_KEYWORD_DETECT,
SOF_COMP_KPB, /* A key phrase buffer component */
SOF_COMP_SELECTOR, /**< channel selector component */
SOF_COMP_DEMUX,
SOF_COMP_ASRC, /**< Asynchronous sample rate converter */
SOF_COMP_DCBLOCK,
SOF_COMP_SMART_AMP, /**< smart amplifier component */
SOF_COMP_MODULE_ADAPTER, /**< module adapter */
/* keep FILEREAD/FILEWRITE as the last ones */
SOF_COMP_FILEREAD = 10000, /**< host test based file IO */
SOF_COMP_FILEWRITE = 10001, /**< host test based file IO */
};

/**
* Trace context.
*/
struct tr_ctx {
const struct sof_uuid_entry* uuid_p; /**< UUID pointer, use SOF_UUID() to init */
uint32_t level; /**< Default log level */
};

/** \addtogroup component_api Component API
* @{
*/
Expand Down
4 changes: 3 additions & 1 deletion src/include/sof/audio/module_adapter/iadk/adsp_stddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#include <user/trace.h>
#include <rtos/string.h>

#ifdef __ZEPHYR__ && !defined MODULE_PRIVAT
#ifdef __ZEPHYR__
#ifndef MODULE_PRIVAT
#include <zephyr/sys/util.h>
#endif
#endif /* __ZEPHYR__ */

#ifdef __XTENSA__
Expand Down
5 changes: 3 additions & 2 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
#ifndef __SOF_AUDIO_MODULE_GENERIC__
#define __SOF_AUDIO_MODULE_GENERIC__

#ifndef MODULE_PRIVAT
#include <sof/audio/component.h>
#ifndef MODULE_PRIVAT
#include <sof/ut.h>
#include <sof/lib/memory.h>
#include <sof/audio/dp_queue.h>
#endif //MODULE_PRIVAT
#include <sof/audio/sink_api.h>
#include <sof/audio/source_api.h>
#include <sof/audio/dp_queue.h>

#include "module_interface.h"
#ifndef MODULE_PRIVAT
#if CONFIG_INTEL_MODULES
Expand Down
161 changes: 81 additions & 80 deletions src/include/sof/audio/pipeline-trace.h
Original file line number Diff line number Diff line change
@@ -1,80 +1,81 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <[email protected]>
*/

#ifndef __SOF_AUDIO_PIPELINE_TRACE_H__
#define __SOF_AUDIO_PIPELINE_TRACE_H__

#include <rtos/sof.h>
#include <sof/trace/trace.h>
#include <user/trace.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>

/* pipeline tracing */
extern struct tr_ctx pipe_tr;

#define trace_pipe_get_tr_ctx(pipe_p) (&(pipe_p)->tctx)
#define trace_pipe_get_id(pipe_p) ((pipe_p)->pipeline_id)
#define trace_pipe_get_subid(pipe_p) ((pipe_p)->comp_id)

/* class (driver) level (no device object) tracing */

#define pipe_cl_err(__e, ...) \
tr_err(&pipe_tr, __e, ##__VA_ARGS__)

#define pipe_cl_warn(__e, ...) \
tr_warn(&pipe_tr, __e, ##__VA_ARGS__)

#define pipe_cl_info(__e, ...) \
tr_info(&pipe_tr, __e, ##__VA_ARGS__)

#define pipe_cl_dbg(__e, ...) \
tr_dbg(&pipe_tr, __e, ##__VA_ARGS__)

/* device tracing */
#if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG)

#if CONFIG_IPC_MAJOR_4
#define __PIPE_FMT "pipe:%u %#x "
#else
#define __PIPE_FMT "pipe:%u.%u "
#endif

#define pipe_err(pipe_p, __e, ...) LOG_ERR(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#define pipe_warn(pipe_p, __e, ...) LOG_WRN(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#define pipe_info(pipe_p, __e, ...) LOG_INF(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#define pipe_dbg(pipe_p, __e, ...) LOG_DBG(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#else

#define pipe_err(pipe_p, __e, ...) \
trace_dev_err(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#define pipe_warn(pipe_p, __e, ...) \
trace_dev_warn(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#define pipe_info(pipe_p, __e, ...) \
trace_dev_info(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#define pipe_dbg(pipe_p, __e, ...) \
trace_dev_dbg(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#endif /* #if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG) */

#endif
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <[email protected]>
*/

#ifndef __SOF_AUDIO_PIPELINE_TRACE_H__
#define __SOF_AUDIO_PIPELINE_TRACE_H__
#ifndef MODULE_PRIVAT
#include <rtos/sof.h>
#include <sof/trace/trace.h>
#include <user/trace.h>
#include <errno.h>
#endif
#include <stdbool.h>
#include <stdint.h>

/* pipeline tracing */
extern struct tr_ctx pipe_tr;

#define trace_pipe_get_tr_ctx(pipe_p) (&(pipe_p)->tctx)
#define trace_pipe_get_id(pipe_p) ((pipe_p)->pipeline_id)
#define trace_pipe_get_subid(pipe_p) ((pipe_p)->comp_id)

/* class (driver) level (no device object) tracing */

#define pipe_cl_err(__e, ...) \
tr_err(&pipe_tr, __e, ##__VA_ARGS__)

#define pipe_cl_warn(__e, ...) \
tr_warn(&pipe_tr, __e, ##__VA_ARGS__)

#define pipe_cl_info(__e, ...) \
tr_info(&pipe_tr, __e, ##__VA_ARGS__)

#define pipe_cl_dbg(__e, ...) \
tr_dbg(&pipe_tr, __e, ##__VA_ARGS__)

/* device tracing */
#if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG)

#if CONFIG_IPC_MAJOR_4
#define __PIPE_FMT "pipe:%u %#x "
#else
#define __PIPE_FMT "pipe:%u.%u "
#endif

#define pipe_err(pipe_p, __e, ...) LOG_ERR(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#define pipe_warn(pipe_p, __e, ...) LOG_WRN(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#define pipe_info(pipe_p, __e, ...) LOG_INF(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#define pipe_dbg(pipe_p, __e, ...) LOG_DBG(__PIPE_FMT __e, trace_pipe_get_id(pipe_p), \
trace_pipe_get_subid(pipe_p), ##__VA_ARGS__)

#else

#define pipe_err(pipe_p, __e, ...) \
trace_dev_err(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#define pipe_warn(pipe_p, __e, ...) \
trace_dev_warn(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#define pipe_info(pipe_p, __e, ...) \
trace_dev_info(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#define pipe_dbg(pipe_p, __e, ...) \
trace_dev_dbg(trace_pipe_get_tr_ctx, trace_pipe_get_id, \
trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__)

#endif /* #if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG) */

#endif
2 changes: 2 additions & 0 deletions xtos/include/sof/lib/mailbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#include <sof/common.h>
#include <kernel/mailbox.h>
#include <platform/lib/mailbox.h>
#ifndef MODULE_PRIVAT
#include <rtos/panic.h>
#include <rtos/cache.h>
#endif
#include <sof/lib/memory.h>
#include <rtos/string.h>
#include <stddef.h>
Expand Down
4 changes: 2 additions & 2 deletions zephyr/include/rtos/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#ifndef __ZEPHYR_RTOS_ALLOC_H__
#define __ZEPHYR_RTOS_ALLOC_H__

#ifndef MODULE_PRIVAT
#include <rtos/bit.h>
#include <rtos/string.h>
#include <sof/trace/trace.h>
#include <user/trace.h>

#endif
#include <stddef.h>
#include <stdint.h>

Expand Down
Loading

0 comments on commit 27a5d7e

Please sign in to comment.