Skip to content

Commit

Permalink
Merge branch 'main' into imx8qm_qxp_fix
Browse files Browse the repository at this point in the history
Signed-off-by: Laurentiu Mihalcea <[email protected]>
  • Loading branch information
LaurentiuM1234 authored Nov 9, 2023
2 parents 5141359 + b7d7fb0 commit f2f29cf
Show file tree
Hide file tree
Showing 78 changed files with 425 additions and 231 deletions.
24 changes: 19 additions & 5 deletions lmdk/cmake/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ foreach(MODULE ${MODULES_LIST})
add_executable(${MODULE})
add_subdirectory(${LMDK_BASE}/modules/${MODULE} ${MODULE}_module)

### set_target_properties(${MODULE} PROPERTIES OUTPUT_NAME ${MODULE}.mod)
# uncomment line below to compile module with debug information
#target_compile_options(${MODULE} PUBLIC "-g3")

target_include_directories(${MODULE} PRIVATE
"${LMDK_BASE}/include"
Expand All @@ -35,9 +36,9 @@ foreach(MODULE ${MODULES_LIST})
)

target_link_options(${MODULE} PRIVATE
"-nostdlib" "-nodefaultlibs"
"-nostartfiles"
"-Wl,--no-undefined" "-Wl,--unresolved-symbols=report-all" "-Wl,--error-unresolved-symbols"
#"-Wl,--gc-sections" # may remove .bss and that will result in rimage error, do not use for now
"-Wl,--gc-sections"
"-Wl,-Map,$<TARGET_FILE:${MODULE}>.map" # optional: just for debug
"-T" "${MODULE}_ldscripts/elf32xtensa.x"
)
Expand All @@ -55,13 +56,26 @@ cmake_path(APPEND SOF_BASE "../build-rimage" OUTPUT_VARIABLE RIMAGE_SOF_INSTALL_
cmake_path(NORMAL_PATH RIMAGE_SOF_INSTALL_DIR)
cmake_path(ABSOLUTE_PATH SIGNING_KEY BASE_DIRECTORY ${CMAKE_SOURCE_DIR} NORMALIZE)

foreach(MOD_NAME IN LISTS MODULES_LIST)
list(APPEND RIMAGE_MODULES_LIST ${MOD_NAME}.mod)

# Change .module section flags to tell rimage to not include it in a final image
add_custom_target(${MOD_NAME}.mod
COMMENT "Preparing .mod(ule) files for rimage"
DEPENDS ${MOD_NAME}
COMMAND ${CMAKE_OBJCOPY}
--set-section-flags .module=noload,readonly
${MOD_NAME} ${MOD_NAME}.mod
)
endforeach()

find_program(RIMAGE_COMMAND NAMES rimage
PATHS "${RIMAGE_INSTALL_DIR}"
HINTS "${RIMAGE_SOF_INSTALL_DIR}"
REQUIRED)

add_custom_target(${PROJECT_NAME}_target ALL
DEPENDS ${MODULES_LIST}
COMMAND ${RIMAGE_COMMAND} -k ${SIGNING_KEY} -f 2.0.0 -b 1 -o ${RIMAGE_OUTPUT_FILE} -c ${TOML} -e ${MODULES_LIST}
DEPENDS ${RIMAGE_MODULES_LIST}
COMMAND ${RIMAGE_COMMAND} -k ${SIGNING_KEY} -f 2.0.0 -b 1 -o ${RIMAGE_OUTPUT_FILE} -c ${TOML} -e ${RIMAGE_MODULES_LIST}
COMMAND ${CMAKE_COMMAND} -E cat ${RIMAGE_OUTPUT_FILE}.xman ${RIMAGE_OUTPUT_FILE} > ${OUTPUT_FILE}
)
2 changes: 1 addition & 1 deletion lmdk/cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ cmake_path(ABSOLUTE_PATH LMDK_BASE NORMALIZE)
set(SOF_BASE ${LMDK_BASE}/..)
cmake_path(ABSOLUTE_PATH SOF_BASE NORMALIZE)

set(RIMAGE_INCLUDE_DIR ${SOF_BASE}/rimage/src/include)
set(RIMAGE_INCLUDE_DIR ${SOF_BASE}/tools/rimage/src/include)
cmake_path(ABSOLUTE_PATH RIMAGE_INCLUDE_DIR NORMALIZE)
13 changes: 13 additions & 0 deletions lmdk/cmake/ldscripts/bss_linker_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,18 @@ SECTIONS {
_next_end = ABSOLUTE(.);
*(.bss)
*(.bss.*)

/* Heap memory */
. = ALIGN(4);
__stack = .;
_end = .;
KEEP(*(.heap_mem))

/* Use the unused rest of the memory page as a heap */
. = ALIGN(4096);

/* The sbrk function implementation by xtensa incorrectly checks whether the allocated
memory block fits in the heap, so we have to add 1 to the end of the heap marker. */
_heap_sentry = . + 1;
} >HPSRAM_seg : bss_phdr
}
7 changes: 4 additions & 3 deletions lmdk/cmake/ldscripts/data_linker_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ SECTIONS {
_data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.*.data)
_data_end = ABSOLUTE(.);
} >HPSRAM_seg : data_phdr

.rodata : ALIGN(4096) {
.rodata : {
_rodata_start = ABSOLUTE(.);
*(.gnu.linkonce.r.*)
*(.rodata)
Expand All @@ -24,7 +25,7 @@ SECTIONS {
} >HPSRAM_seg : rodata_phdr

/* Module manifest is here */
.module : ALIGN(4096) {
.module 0 : {
KEEP(*(.module))
} >HPSRAM_seg : rodata_phdr
}
}
2 changes: 1 addition & 1 deletion lmdk/cmake/ldscripts/text_linker_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PHDRS {
SECTIONS {
.text : ALIGN(4096) {
_text_start = ABSOLUTE(.);
*(.buildinfo)
KEEP(*(.buildinfo))
*(.gnu.linkonce.literal.*)
*(.gnu.linkonce.lit4)
*(.literal)
Expand Down
4 changes: 2 additions & 2 deletions lmdk/cmake/xtensa-toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ cmake_path(APPEND XTENSA_TOOLCHAIN_PATH "XtensaTools" OUTPUT_VARIABLE TOOLCHAIN_
set(CROSS_COMPILE xt-)

# clang or xcc
find_program(CMAKE_C_COMPILER NAMES ${CROSS_COMPILE}xcc
find_program(CMAKE_C_COMPILER NAMES ${CROSS_COMPILE}clang
PATHS ${TOOLCHAIN_BASE} PATH_SUFFIXES "bin" REQUIRED NO_DEFAULT_PATH
)
# clang++ or xc++
find_program(CMAKE_CXX_COMPILER NAMES ${CROSS_COMPILE}xc++
find_program(CMAKE_CXX_COMPILER NAMES ${CROSS_COMPILE}clang++
PATHS ${TOOLCHAIN_BASE} PATH_SUFFIXES "bin" REQUIRED NO_DEFAULT_PATH
)
find_program(CMAKE_LD NAMES ${CROSS_COMPILE}ld
Expand Down
9 changes: 9 additions & 0 deletions scripts/cmake/misc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ function(get_optimization_flag OUT_VAR)
endif()
endfunction()

# Zephyr duplicate in sof/zephyr/CMakeLists.txt; keep in sync
macro(is_zephyr ret)
if(CONFIG_ZEPHYR_SOF_MODULE)
set(${ret} TRUE)
else()
set(${ret} FALSE)
endif()
endmacro()

# Adds sources to target like target_sources, but assumes that
# paths are relative to subdirectory.
# Works like:
Expand Down
4 changes: 2 additions & 2 deletions scripts/rebuild-testbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ setup_xtensa_tools_build()
BUILD_TYPE=xt
BUILD_TARGET=
BUILD_DIR_NAME=build_xt_testbench
COMPILER="xt-xcc"

# check needed environment variables
test -n "${XTENSA_TOOLS_ROOT}" || die "XTENSA_TOOLS_ROOT need to be set.\n"
Expand All @@ -72,11 +73,10 @@ setup_xtensa_tools_build()
test -n "${XTENSA_CORE}" ||
die "Illegal platform $BUILD_PLATFORM, no XTENSA_CORE found.\n"

compiler="xt-xcc"
install_bin=install/tools/$XTENSA_TOOLS_VERSION/XtensaTools/bin
tools_bin=$XTENSA_TOOLS_ROOT/$install_bin
testbench_sections="-Wl,--sections-placement $BUILD_TESTBENCH_DIR/testbench_xcc_sections.txt"
export CC=$tools_bin/$compiler
export CC=$tools_bin/$COMPILER
export LD=$tools_bin/xt-ld
export OBJDUMP=$tools_bin/xt-objdump
export LDFLAGS="-mlsp=sim $testbench_sections"
Expand Down
6 changes: 6 additions & 0 deletions scripts/set_xtensa_params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,10 @@ case "$platform" in
HOST="xtensa-mt8195-elf"
XTENSA_TOOLS_VERSION="RI-2019.1-linux"
;;
mtl)
PLATFORM="mtl"
XTENSA_CORE="ace10_LX7HiFi4_2022_10"
XTENSA_TOOLS_VERSION="RI-2022.10-linux"
COMPILER="xt-clang"
;;
esac
4 changes: 3 additions & 1 deletion src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ static int copier_init(struct processing_module *mod)
for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++)
cd->out_fmt[i] = cd->config.out_fmt;

ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id);
ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE,
config->pipeline_id,
IPC_COMP_IGNORE_REMOTE);
if (!ipc_pipe) {
comp_err(dev, "pipeline %d is not existed", config->pipeline_id);
ret = -EPIPE;
Expand Down
22 changes: 19 additions & 3 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <google_rtc_audio_processing_sof_message_reader.h>

#define GOOGLE_RTC_AUDIO_PROCESSING_FREQENCY_TO_PERIOD_FRAMES 100
#define GOOGLE_RTC_NUM_INPUT_PINS 2

LOG_MODULE_REGISTER(google_rtc_audio_processing, CONFIG_SOF_LOG_LEVEL);

Expand Down Expand Up @@ -85,6 +86,7 @@ void GoogleRtcFree(void *ptr)
#if CONFIG_IPC_MAJOR_4
static void google_rtc_audio_processing_params(struct processing_module *mod)
{
struct google_rtc_audio_processing_comp_data *cd = module_get_private_data(mod);
struct sof_ipc_stream_params *params = mod->stream_params;
struct comp_buffer *sinkb, *sourceb;
struct list_item *source_list;
Expand All @@ -95,7 +97,10 @@ static void google_rtc_audio_processing_params(struct processing_module *mod)

list_for_item(source_list, &dev->bsource_list) {
sourceb = container_of(source_list, struct comp_buffer, sink_list);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);
if (IPC4_SINK_QUEUE_ID(source->id) == SOF_AEC_FEEDBACK_QUEUE_ID)
ipc4_update_buffer_format(sourceb, &cd->config.reference_fmt);
else
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);
}

sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
Expand Down Expand Up @@ -385,9 +390,20 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
md->private = cd;

#if CONFIG_IPC_MAJOR_4
struct module_config *cfg = &md->cfg;
const struct ipc4_base_module_extended_cfg *base_cfg = md->cfg.init_data;
struct ipc4_input_pin_format reference_fmt, output_fmt;
const size_t size = sizeof(struct ipc4_input_pin_format);

cd->config.base_cfg = base_cfg->base_cfg;

/* Copy the reference format from input pin 1 format */
memcpy_s(&reference_fmt, size,
&base_cfg->base_cfg_ext.pin_formats[size], size);
memcpy_s(&output_fmt, size,
&base_cfg->base_cfg_ext.pin_formats[size * GOOGLE_RTC_NUM_INPUT_PINS], size);

cd->config = *(const struct sof_ipc4_aec_config *)cfg->init_data;
cd->config.reference_fmt = reference_fmt.audio_fmt;
cd->config.output_fmt = output_fmt.audio_fmt;
#endif

cd->tuning_handler = comp_data_blob_handler_new(dev);
Expand Down
24 changes: 23 additions & 1 deletion src/idc/idc.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,25 @@ static int idc_reset(uint32_t comp_id)
return ret;
}

/**
* \brief Executes IDC component reset message.
* \param[in] comp_id Component id to be reset.
* \return Error code.
*/
static int idc_comp_free(uint32_t comp_id)
{
struct ipc *ipc = ipc_get();
struct ipc_comp_dev *icd;
int ret;

icd = ipc_get_comp_by_id(ipc, comp_id);
if (!icd)
return -ENODEV;

ret = ipc_comp_free(ipc, comp_id);
return ret;
}

/**
* \brief Executes IDC pipeline set state message.
* \param[in] ppl_id Pipeline id to be triggered.
Expand All @@ -329,7 +348,7 @@ static int idc_ppl_state(uint32_t ppl_id, uint32_t phase)
struct ipc_comp_dev *ppl_icd;
uint32_t cmd = *(uint32_t *)payload;

ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id);
ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id, IPC_COMP_IGNORE_REMOTE);
if (!ppl_icd) {
tr_err(&idc_tr, "idc: comp %d not found", ppl_id);
return IPC4_INVALID_RESOURCE_ID;
Expand Down Expand Up @@ -429,6 +448,9 @@ void idc_cmd(struct idc_msg *msg)
case iTS(IDC_MSG_GET_ATTRIBUTE):
ret = idc_get_attribute(msg->extension);
break;
case iTS(IDC_MSG_FREE):
ret = idc_comp_free(msg->extension);
break;
#endif
case iTS(IDC_MSG_PARAMS):
ret = idc_params(msg->extension);
Expand Down
6 changes: 5 additions & 1 deletion src/include/sof/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ struct ipc_msg;
#define COMP_TYPE_BUFFER 2
#define COMP_TYPE_PIPELINE 3

#define IPC_COMP_ALL 0
#define IPC_COMP_IGNORE_REMOTE 1

/* IPC generic component device */
struct ipc_comp_dev {
uint16_t type; /* COMP_TYPE_ */
Expand Down Expand Up @@ -179,10 +182,11 @@ struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t i
* @param ipc The global IPC context.
* @param type The component type.
* @param ppl_id The pipeline ID.
* @param ignore_remote Omit component from different core if set to IPC_COMP_IGNORE_REMOTE
* @return component device or NULL.
*/
struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id);
uint32_t ppl_id, uint32_t ignore_remote);
/**
* \brief Get buffer device from pipeline ID.
* @param ipc The global IPC context.
Expand Down
16 changes: 16 additions & 0 deletions src/init/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# SPDX-License-Identifier: BSD-3-Clause

is_zephyr(it_is)
if(it_is) ### Zephyr ###


zephyr_library_sources(
init.c
ext_manifest.c
)


else() ### Not Zephyr ###


add_local_sources(sof init.c)

add_library(ext_manifest STATIC "")
Expand All @@ -21,3 +34,6 @@ sof_append_relative_path_definitions(ext_manifest)

target_link_libraries(ext_manifest sof_options)
target_link_libraries(sof_static_libraries INTERFACE ext_manifest)


endif() # Zephyr
27 changes: 26 additions & 1 deletion src/ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,33 @@ elseif (CONFIG_IPC_MAJOR_4)
add_subdirectory(ipc4)
endif()

add_local_sources(sof
set(base_files
ipc-common.c
ipc-helper.c
)

is_zephyr(it_is)
if(it_is) ### Zephyr ###

zephyr_library_sources(
${base_files}
dma-copy.c
)

if (CONFIG_SOC_SERIES_INTEL_CAVS_V25 OR CONFIG_SOC_SERIES_INTEL_ACE)
zephyr_library_sources(
ipc-zephyr.c
)
endif()


else() ### Not Zephyr ###


add_local_sources(sof
${base_files}
)

if (CONFIG_TRACE)
add_local_sources(sof
dma-copy.c)
Expand All @@ -19,3 +41,6 @@ endif()
if (CONFIG_LIBRARY)
return()
endif()


endif() # Zephyr
Loading

0 comments on commit f2f29cf

Please sign in to comment.