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 Jan 10, 2024
1 parent ddab8d4 commit 5e9f9db
Show file tree
Hide file tree
Showing 19 changed files with 328 additions and 271 deletions.
1 change: 0 additions & 1 deletion lmdk/libraries/module_example/module_example_mtl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ length = "0x0" # calculated by rimage

[signed_pkg]
name = "ADSP"
partition_usage = "0x23"
[[signed_pkg.module]]
name = "ADSP.met"

Expand Down
3 changes: 2 additions & 1 deletion lmdk/modules/up_down_mixer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ target_compile_definitions(up_down_mixer PRIVATE __ZEPHYR__=1
CONFIG_IPC_MAJOR_4=1
CONFIG_LIBRARY=1
__ZEPHYR_RTOS_IDC_H__=1
MODULE_PRIVAT=1)
MODULE_PRIVAT=1
XCHAL_HAVE_HIFI3=1)

message( ${LMDK_DIR}${SOF_SRC_DIR}../posix/include )

Expand Down
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
1 change: 0 additions & 1 deletion src/audio/up_down_mixer/up_down_mixer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ length = "0x0" # calculated by rimage

[signed_pkg]
name = "ADSP"
partition_usage = "0x23"
[[signed_pkg.module]]
name = "ADSP.met"

Expand Down
3 changes: 1 addition & 2 deletions src/audio/up_down_mixer/up_down_mixer_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

#include "up_down_mixer.h"

#if defined(__XCC__) && XCHAL_HAVE_HIFI3 || ~defined MODULE_PRIVAT

#if defined(__XCC__) && XCHAL_HAVE_HIFI3
#include <xtensa/tie/xt_hifi3.h>
#include <errno.h>
#include <stddef.h>
Expand Down
4 changes: 3 additions & 1 deletion src/audio/up_down_mixer/up_down_mixer_ipc4.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ enum up_down_mix_coeff_select {

#define UP_DOWN_MIX_COEFFS_LENGTH 8
#define IPC4_UP_DOWN_MIXER_MODULE_OUTPUT_PINS_COUNT 1

#ifndef __packed
#define __packed __attribute__((packed))
#endif
struct ipc4_up_down_mixer_module_cfg {
struct ipc4_base_module_cfg base_cfg;

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
Loading

0 comments on commit 5e9f9db

Please sign in to comment.