Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Kconfig.sof
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rsource "Kconfig.xtos"

rsource "src/Kconfig"

if ZEPHYR_SOF_MODULE
if ZEPHYR_SOF_MODULE || SOF_FULL_ZEPHYR_APPLICATION
rsource "Kconfig.zephyr-log"
endif

Expand Down
39 changes: 37 additions & 2 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,46 @@ endif()
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(sample_sof)

add_subdirectory(../zephyr sof_zephyr)

target_sources(app PRIVATE
src/main.c
)

zephyr_library_include_directories(app PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../src/arch/xtensa/include
target_sources_ifdef(CONFIG_USB_DEVICE_STACK_NEXT app PRIVATE
src/usbd_init.c
)

target_include_directories(app PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/../src/include
${CMAKE_CURRENT_SOURCE_DIR}/../zephyr/include
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/${PLATFORM}/include
${PROJECT_BINARY_DIR}/include/generated
)

target_link_libraries(app PRIVATE SOF modules_sof)
if(TARGET uuid_reg_h)
add_dependencies(app uuid_reg_h modules_sof)
endif()

if(CONFIG_XTENSA)
target_include_directories(app PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../src/arch/xtensa/include
)
endif()

function(sof_append_relative_path_definitions target)
get_target_property(sources ${target} SOURCES)
foreach(src ${sources})
get_filename_component(ABS_PATH ${src} ABSOLUTE)
file(RELATIVE_PATH rel ${PROJECT_SOURCE_DIR} ${ABS_PATH})
set_property(
SOURCE ${src}
APPEND
PROPERTY COMPILE_DEFINITIONS
RELATIVE_FILE="${rel}")
endforeach()
endfunction()

sof_append_relative_path_definitions(app)
5 changes: 5 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ choice COMPILER_CODEGEN_VLIW
endchoice

source "Kconfig.zephyr"
source "samples/subsys/usb/common/Kconfig.sample_usbd"

if !ZEPHYR_SOF_MODULE
rsource "../zephyr/Kconfig"
endif

if SOC_FAMILY_INTEL_ADSP
rsource "boards/intel_adsp/Kconfig.defconfig"
Expand Down
89 changes: 89 additions & 0 deletions app/boards/teensy41.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Target Platform & SOF Core
CONFIG_PLATFORM_TEENSY41=y
CONFIG_SOF_FULL_ZEPHYR_APPLICATION=y
CONFIG_IPC_MAJOR_4=y
CONFIG_COMP_BASEFW_IPC4=n
CONFIG_CROSS_CORE_STREAM=n
CONFIG_STATIC_PIPELINE=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
CONFIG_SYS_HEAP_BIG_ONLY=y
CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_BUILD_OUTPUT_BIN=y

# Zephyr DAI Drivers for NXP SAI
CONFIG_DAI=y
CONFIG_DAI_NXP_SAI=y
CONFIG_PINCTRL=y
CONFIG_DMA=y
CONFIG_DMA_MCUX_EDMA=y
CONFIG_DMA_TCD_QUEUE_SIZE=8
CONFIG_DMA_MCUX_USE_DTCM_FOR_DMA_DESCRIPTORS=n

# Audio Processing Modules & ARM SIMD Optimizations
CONFIG_COMP_VOLUME=y
CONFIG_VOLUME_ARM_SIMD=y
CONFIG_COMP_IIR=y
CONFIG_EQ_IIR_ARM_SIMD=y
CONFIG_FILTER_ARM_SIMD=y
CONFIG_COMP_FIR=y
CONFIG_COMP_DRC=y
CONFIG_DRC_ARM_SIMD=y
CONFIG_COMP_CROSSOVER=y
CONFIG_COMP_DCBLOCK=y
CONFIG_DCBLOCK_ARM_SIMD=y
CONFIG_COMP_MULTIBAND_DRC=y
CONFIG_COMP_TDFB=y
CONFIG_COMP_USB_AUDIO=y
CONFIG_COMP_LEVEL_MULTIPLIER=y
CONFIG_COMP_SEL=y
CONFIG_COMP_MUX=y
CONFIG_COMP_MIXER=y
CONFIG_MIXER_ARM_SIMD=y
CONFIG_FORMAT_CONVERT_ARM_SIMD=y

# USB Device Stack Next & UAC2 Class
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_CDC_ACM_SERIAL_INITIALIZE_AT_BOOT=n
CONFIG_USBD_AUDIO2_CLASS=y
CONFIG_UDC_ENABLE_SOF=y
CONFIG_UDC_NXP_EHCI=y
CONFIG_UDC_BUF_COUNT=64
CONFIG_UDC_BUF_POOL_SIZE=16384
CONFIG_UDC_WORKQUEUE_PRIORITY=-10
CONFIG_UDC_NXP_EVENT_COUNT=16
CONFIG_UDC_WORKQUEUE_STACK_SIZE=2048
CONFIG_LL_THREAD_PRIORITY=0

# USB Device Identification
CONFIG_SAMPLE_USBD_VID=0x16C0
CONFIG_SAMPLE_USBD_PID=0x04D2
CONFIG_SAMPLE_USBD_MANUFACTURER="PJRC"
CONFIG_SAMPLE_USBD_PRODUCT="SOF Teensy 4.1 Audio A"

# System Resources & Memory
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_USBD_THREAD_STACK_SIZE=4096
CONFIG_ISR_STACK_SIZE=4096
CONFIG_HW_STACK_PROTECTION=n
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_TICKLESS_KERNEL=n
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

# Logging & UART Console
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_MAX_LEVEL=4
CONFIG_SOF_LOG_LEVEL_INF=y
CONFIG_DAI_LOG_LEVEL_INF=y
CONFIG_USBD_UAC2_LOG_LEVEL_INF=y
CONFIG_UDC_DRIVER_LOG_LEVEL_INF=y
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_LOG_MODE_OVERFLOW=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PROCESS_THREAD=n
CONFIG_EARLY_CONSOLE=n

# SOF Low Latency Scheduler Statistics Logging
CONFIG_SCHEDULE_LL_STATS_LOG=n
173 changes: 173 additions & 0 deletions app/boards/teensy41.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#include <zephyr/dt-bindings/usb/audio.h>

/ {
chosen {
zephyr,console = &lpuart6;
zephyr,shell-uart = &lpuart6;
};

uac2_card: usb_audio2 {
compatible = "zephyr,uac2";
status = "okay";
full-speed;
high-speed;
audio-function = <AUDIO_FUNCTION_IO_BOX>;

uac_aclk: aclk {
compatible = "zephyr,uac2-clock-source";
clock-type = "internal-programmable";
frequency-control = "host-programmable";
sampling-frequencies = <48000>;
sof-synchronized;
};

/* ===== Playback from Host (ISO OUT) ===== */
i2s_out_terminal: i2s_out_terminal {
compatible = "zephyr,uac2-input-terminal";
clock-source = <&uac_aclk>;
terminal-type = <USB_TERMINAL_STREAMING>;
front-left;
front-right;
};

i2s_fu: i2s_fu {
compatible = "zephyr,uac2-feature-unit";
data-source = <&i2s_out_terminal>;
mute-control = "host-programmable";
volume-control = "host-programmable";
};

pb_eq_fu: pb_eq_fu {
compatible = "zephyr,uac2-feature-unit";
data-source = <&i2s_fu>;
mute-control = "host-programmable";
};

pb_drc_fu: pb_drc_fu {
compatible = "zephyr,uac2-feature-unit";
data-source = <&pb_eq_fu>;
mute-control = "host-programmable";
};

i2s_speaker: i2s_speaker {
compatible = "zephyr,uac2-output-terminal";
data-source = <&pb_drc_fu>;
clock-source = <&uac_aclk>;
terminal-type = <OUTPUT_TERMINAL_SPEAKER>;
assoc-terminal = <&i2s_mic>;
};

/* ===== Capture to Host (ISO IN) ===== */
i2s_mic: i2s_mic {
compatible = "zephyr,uac2-input-terminal";
clock-source = <&uac_aclk>;
terminal-type = <INPUT_TERMINAL_MICROPHONE>;
front-left;
front-right;
};

cap_eq_fu: cap_eq_fu {
compatible = "zephyr,uac2-feature-unit";
data-source = <&i2s_mic>;
mute-control = "host-programmable";
};

i2s_in_fu: i2s_in_fu {
compatible = "zephyr,uac2-feature-unit";
data-source = <&cap_eq_fu>;
mute-control = "host-programmable";
volume-control = "host-programmable";
};

i2s_in_terminal: i2s_in_terminal {
compatible = "zephyr,uac2-output-terminal";
data-source = <&i2s_in_fu>;
clock-source = <&uac_aclk>;
terminal-type = <USB_TERMINAL_STREAMING>;
};

/* Audio Streaming Interfaces */
as_i2s_out: as_i2s_out {
compatible = "zephyr,uac2-audio-streaming";
linked-terminal = <&i2s_out_terminal>;
subslot-size = <2>;
bit-resolution = <16>;
};

as_i2s_in: as_i2s_in {
compatible = "zephyr,uac2-audio-streaming";
linked-terminal = <&i2s_in_terminal>;
subslot-size = <2>;
bit-resolution = <16>;
};
};
};

&pinctrl {
pinmux_sai1: pinmux_sai1 {
group0 {
pinmux = <&iomuxc_gpio_b1_01_sai1_tx_data0>,
<&iomuxc_gpio_b0_11_sai1_tx_data2>,
<&iomuxc_gpio_b1_00_sai1_rx_data0>,
<&iomuxc_gpio_ad_b1_10_sai1_rx_sync>,
<&iomuxc_gpio_ad_b1_11_sai1_rx_bclk>,
<&iomuxc_gpio_ad_b1_09_sai1_mclk>;
drive-strength = "r0-6";
slew-rate = "slow";
nxp,speed = "100-mhz";
input-enable;
};
};

pinmux_spdif: pinmux_spdif {
group0 {
pinmux = <&iomuxc_gpio_ad_b1_02_spdif_out>,
<&iomuxc_gpio_ad_b1_03_spdif_in>;
drive-strength = "r0-6";
slew-rate = "fast";
nxp,speed = "100-mhz";
input-enable;
};
};
};

/delete-node/ &sai1;

/ {
soc {
sai1: dai@40384000 {
compatible = "nxp,dai-sai";
reg = <0x40384000 0x4000>;
interrupts = <56 0>;
clocks = <&ccm IMX_CCM_SAI1_CLK 0x7c 18>;
clock-names = "bus";
pinctrl-0 = <&pinmux_sai1>;
pinctrl-names = "default";
dai-index = <1>;
dmas = <&edma0 0 20>, <&edma0 1 19>;
dma-names = "tx", "rx";
tx-fifo-watermark = <16>;
rx-fifo-watermark = <16>;
fifo-depth = <32>;
tx-sync-mode = <1>;
rx-sync-mode = <0>;
tx-dataline = <2>;
status = "okay";
};

spdif: dai@40380000 {
compatible = "nxp,dai-spdif";
reg = <0x40380000 0x1000>;
interrupts = <60 0>;
clocks = <&ccm IMX_CCM_SPDIF0_CLK 0x7c 14>;
clock-names = "bus";
pinctrl-0 = <&pinmux_spdif>;
pinctrl-names = "default";
dai-index = <0>;
dmas = <&edma0 2 86>, <&edma0 3 85>;
dma-names = "tx", "rx";
status = "okay";
};
};
};

Loading
Loading