From ab07ada908b82340e7acd899e85a9802cf8a9057 Mon Sep 17 00:00:00 2001
From: chenlh <2008get@163.com>
Date: 星期四, 18 九月 2025 14:09:22 +0800
Subject: [PATCH] 首轮测试版代码常规上传
---
src/tg/tg_adapter.h | 4
src/protocol.h | 3
drv/DMCInit.h | 1
src/tg/tg_scene.h | 48
src/tg/tg_scene.cpp | 540 ++++++++++++--
system/startup_ldf/app_startup.s | 6
inc/ModuleProAPI.h | 1
inc/config.h | 17
src/f2f.c | 38 +
src/protocol_internal.h | 3
src/tg/tg_param_convert.cpp | 76 +
system/startup_ldf/app.ldf | 15
src/ModuleExport.cpp | 15
src/ModuleExport.h | 16
src/scene.cpp | 80 +
lib/ModuleProcLibs.dlb | 0
drv/spi.c | 14
.settings/org.eclipse.core.resources.prefs | 3
src/messageproc.cpp | 94 ++
drv/pwr.c | 1
sch/天宫DSP摘记.docx | 0
src/tg/tg_user_ctrl.h | 29
system/startup_ldf/app_heaptab.c | 13
.cproject | 33
src/tob.cpp | 327 ++++----
.settings/ToolChain.prefs | 2
src/tg/tg_config.h | 14
/dev/null | 113 ---
system/startup_ldf/app_IVT.s | 4
src/param_ctrl.h | 43 +
src/tg/tg_param_convert.h | 1
sch/dsp-21569_V1.pdf | 0
src/main.cpp | 56 +
src/tg/tg_adapter.cpp | 189 ++++-
drv/board.c | 5
src/messageproc.h | 8
drv/board.h | 11
drv/FIR_acc.c | 3
src/tg/tg_param_ctrl.cpp | 4
src/tob.h | 16
lib/aer.dlb | 0
src/hw_adapter.h | 26
src/frames.cpp | 4
drv/sport.c | 5
src/tg/tg_user_ctrl.cpp | 107 +-
src/scene.h | 8
src/tg/module_def.h | 18
drv/sport.h | 2
48 files changed, 1,317 insertions(+), 699 deletions(-)
diff --git a/.cproject b/.cproject
index 3a90440..50e78eb 100644
--- a/.cproject
+++ b/.cproject
@@ -30,8 +30,8 @@
<inputType id="assembler.input.1304626576" name="Assembler Source" superClass="assembler.input"/>
</tool>
<tool id="sharc.toolchain.compiler.913943905" name="CrossCore SHARC C/C++ Compiler" superClass="sharc.toolchain.compiler">
- <option id="compiler.option.optimization.556394403" name="Enable optimization (-O)" superClass="compiler.option.optimization" useByScannerDiscovery="false"/>
- <option id="compiler.option.debugcode.900335004" name="Generate debug information (-g)" superClass="compiler.option.debugcode" useByScannerDiscovery="false"/>
+ <option id="compiler.option.optimization.556394403" name="Enable optimization (-O)" superClass="compiler.option.optimization" useByScannerDiscovery="false" value="false" valueType="boolean"/>
+ <option id="compiler.option.debugcode.900335004" name="Generate debug information (-g)" superClass="compiler.option.debugcode" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="compiler.option.proc.775463007" name="-proc" superClass="compiler.option.proc" useByScannerDiscovery="false" value=" ADSP-21569" valueType="string"/>
<option id="compiler.option.sirevision.375383135" name="-si-revision" superClass="compiler.option.sirevision" useByScannerDiscovery="false" value=" 0.0" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="compiler.option.preprocessdefs.200157960" name="Preprocessor definitions (-D):" superClass="compiler.option.preprocessdefs" useByScannerDiscovery="false" valueType="definedSymbols">
@@ -45,6 +45,7 @@
</option>
<option id="compiler.option.compilerswitch.182237227" name="Compiler Switch" superClass="compiler.option.compilerswitch" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="compiler.option.cpp11.976576354" name="Compile C++ source files with C++11 feature extensions (-c++11)" superClass="compiler.option.cpp11" useByScannerDiscovery="false" value="true" valueType="boolean"/>
+ <option id="compiler.option.interprocdoptim.1504058608" name="Interprocedural optimization (-ipa)" superClass="compiler.option.interprocdoptim" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<inputType id="compiler.inputType.1651873364" name="C/C++ Source" superClass="compiler.inputType"/>
</tool>
<tool id="sharc.toolchain.linker.1433934460" name="CrossCore SHARC Linker" superClass="sharc.toolchain.linker">
@@ -75,14 +76,14 @@
<tool id="sharc.toolchain.loader.1387296196" name="CrossCore SHARC Loader" superClass="sharc.toolchain.loader">
<option id="loader.option.proc.1054273039" name="-proc" superClass="loader.option.proc" useByScannerDiscovery="false" value=" ADSP-21569" valueType="string"/>
<option id="loader.option.sirevision.439317339" name="-si-revision" superClass="loader.option.sirevision" useByScannerDiscovery="false" value=" 0.0" valueType="string"/>
- <option id="sharc.loader.option.kernelfile.696987039" name="Kernel file (-l)" superClass="sharc.loader.option.kernelfile" useByScannerDiscovery="false" value="C:\Analog Devices\CrossCore Embedded Studio 2.11.0\SHARC\ldr\null.dxe" valueType="string"/>
- <option id="sharc.loader.option.enumerated.bootmode.568320891" superClass="sharc.loader.option.enumerated.bootmode" useByScannerDiscovery="false" value="sharc.loader.option.boot.enumerated.spislave" valueType="enumerated"/>
- <option id="sharc.loader.option.enumerated.bootformat.1189547824" superClass="sharc.loader.option.enumerated.bootformat" useByScannerDiscovery="false" value="sharc.loader.option.format.enumerated.binary" valueType="enumerated"/>
- <option id="sharc.loader.option.initfile.1249896984" superClass="sharc.loader.option.initfile" useByScannerDiscovery="false" value="C:\Analog Devices\CrossCore Embedded Studio 2.11.0\SHARC\ldr\ezkit21569_initcode.dxe" valueType="string"/>
+ <option id="sharc.loader.option.kernelfile.696987039" name="Kernel file (-l)" superClass="sharc.loader.option.kernelfile" useByScannerDiscovery="false" value="D:\Program Files\Analog Devices\CrossCore Embedded Studio 2.12.1\SHARC\ldr\null.dxe" valueType="string"/>
+ <option id="sharc.loader.option.enumerated.bootmode.568320891" name="Boot mode (-b)" superClass="sharc.loader.option.enumerated.bootmode" useByScannerDiscovery="false" value="sharc.loader.option.boot.enumerated.spislave" valueType="enumerated"/>
+ <option id="sharc.loader.option.enumerated.bootformat.1189547824" name="Boot format (-f)" superClass="sharc.loader.option.enumerated.bootformat" useByScannerDiscovery="false" value="sharc.loader.option.format.enumerated.binary" valueType="enumerated"/>
+ <option id="sharc.loader.option.initfile.1249896984" name="Initialization file (-init)" superClass="sharc.loader.option.initfile" useByScannerDiscovery="false" value="D:\Program Files\Analog Devices\CrossCore Embedded Studio 2.12.1\SHARC\ldr\ezkit21569_initcode.dxe" valueType="string"/>
</tool>
<tool id="sharc.toolchain.deviceprogrammer.185366862" name="CrossCore SHARC Device Programmer" superClass="sharc.toolchain.deviceprogrammer">
<option id="deviceprogrammer.option.proc.1944618241" name="-proc" superClass="deviceprogrammer.option.proc" useByScannerDiscovery="false" value=" ADSP-21569" valueType="string"/>
- <option id="deviceprogrammer.option.enumerated.fileformat.170825008" superClass="deviceprogrammer.option.enumerated.fileformat" useByScannerDiscovery="false" value="deviceprogrammer.option.format.enumerated.binary" valueType="enumerated"/>
+ <option id="deviceprogrammer.option.enumerated.fileformat.170825008" name="File format" superClass="deviceprogrammer.option.enumerated.fileformat" useByScannerDiscovery="false" value="deviceprogrammer.option.format.enumerated.binary" valueType="enumerated"/>
</tool>
</toolChain>
</folderInfo>
@@ -101,6 +102,22 @@
<tool id="sharc.toolchain.deviceprogrammer.630556623" name="CrossCore SHARC Device Programmer" superClass="sharc.toolchain.deviceprogrammer.185366862"/>
</toolChain>
</folderInfo>
+ <fileInfo id="sharc.toolchain.configuration.debug.986561216.776821550" name="tob.cpp" rcbsApplicability="disable" resourcePath="src/tob.cpp" toolsToInvoke="sharc.toolchain.compiler.913943905.1208184272">
+ <tool id="sharc.toolchain.compiler.913943905.1208184272" name="CrossCore SHARC C/C++ Compiler" superClass="sharc.toolchain.compiler.913943905">
+ <option id="compiler.option.debugcode.1852700867" name="Generate debug information (-g)" superClass="compiler.option.debugcode" useByScannerDiscovery="false" value="true" valueType="boolean"/>
+ <option id="compiler.option.optimization.1367621719" name="Enable optimization (-O)" superClass="compiler.option.optimization" useByScannerDiscovery="false" value="false" valueType="boolean"/>
+ <option id="compiler.option.interprocdoptim.1519443625" name="Interprocedural optimization (-ipa)" superClass="compiler.option.interprocdoptim" useByScannerDiscovery="false" value="true" valueType="boolean"/>
+ <inputType id="compiler.inputType.1256387287" name="C/C++ Source" superClass="compiler.inputType"/>
+ </tool>
+ </fileInfo>
+ <fileInfo id="sharc.toolchain.configuration.debug.986561216.961651879" name="f2f.c" rcbsApplicability="disable" resourcePath="src/f2f.c" toolsToInvoke="sharc.toolchain.compiler.913943905.255253029">
+ <tool id="sharc.toolchain.compiler.913943905.255253029" name="CrossCore SHARC C/C++ Compiler" superClass="sharc.toolchain.compiler.913943905">
+ <option id="compiler.option.debugcode.640011568" name="Generate debug information (-g)" superClass="compiler.option.debugcode" useByScannerDiscovery="false" value="false" valueType="boolean"/>
+ <option id="compiler.option.optimization.1494843332" name="Enable optimization (-O)" superClass="compiler.option.optimization" useByScannerDiscovery="false" value="true" valueType="boolean"/>
+ <option id="compiler.option.interprocdoptim.1022671789" name="Interprocedural optimization (-ipa)" superClass="compiler.option.interprocdoptim" useByScannerDiscovery="false" value="true" valueType="boolean"/>
+ <inputType id="compiler.inputType.142353510" name="C/C++ Source" superClass="compiler.inputType"/>
+ </tool>
+ </fileInfo>
<sourceEntries>
<entry excluding="system|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
@@ -178,7 +195,7 @@
<tool id="sharc.toolchain.loader.1360261758" name="CrossCore SHARC Loader" superClass="sharc.toolchain.loader">
<option id="loader.option.proc.1450984201" name="-proc" superClass="loader.option.proc" value=" ADSP-21569" valueType="string"/>
<option id="loader.option.sirevision.838668312" name="-si-revision" superClass="loader.option.sirevision" value=" 0.0" valueType="string"/>
- <option id="sharc.loader.option.kernelfile.307294945" name="Kernel file (-l)" superClass="sharc.loader.option.kernelfile" value="C:\Analog Devices\CrossCore Embedded Studio 2.11.0\SHARC\ldr\_prom.dxe" valueType="string"/>
+ <option id="sharc.loader.option.kernelfile.307294945" name="Kernel file (-l)" superClass="sharc.loader.option.kernelfile" value="D:\Program Files\Analog Devices\CrossCore Embedded Studio 2.12.1\SHARC\ldr\_prom.dxe" valueType="string"/>
</tool>
<tool id="sharc.toolchain.deviceprogrammer.707828906" name="CrossCore SHARC Device Programmer" superClass="sharc.toolchain.deviceprogrammer">
<option id="deviceprogrammer.option.proc.686495168" name="-proc" superClass="deviceprogrammer.option.proc" value=" ADSP-21569" valueType="string"/>
diff --git a/.settings/ToolChain.prefs b/.settings/ToolChain.prefs
index 98104e7..0416693 100644
--- a/.settings/ToolChain.prefs
+++ b/.settings/ToolChain.prefs
@@ -1,2 +1,2 @@
eclipse.preferences.version=1
-version=2.11.0.0
+version=2.12.1.0
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..372f6d1
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/messageproc.cpp=UTF-8
+encoding//src/tg/tg_scene.cpp=UTF-8
diff --git a/drv/DMCInit.h b/drv/DMCInit.h
index 03f5027..25ff4ca 100644
--- a/drv/DMCInit.h
+++ b/drv/DMCInit.h
@@ -171,6 +171,7 @@
}ADI_DMC_CONFIG;
int dmc_cfg0_init(void);
+void adi_dmc_lane_reset(bool reset);
#ifdef __cplusplus
}
diff --git a/drv/FIR_acc.c b/drv/FIR_acc.c
index a2b0c99..bb94baa 100644
--- a/drv/FIR_acc.c
+++ b/drv/FIR_acc.c
@@ -93,7 +93,8 @@
*pREG_FIR0_CHNPTR = (uint32_t)(saddr(firHead.first->tcb+12));
firHead.clock_start = clock();
//Initializing the chain pointer register
- *pREG_FIR0_CTL1 = BITM_FIR_CTL1_EN|BITM_FIR_CTL1_DMAEN|(firHead.num -1)<<BITP_FIR_CTL1_CH|BITM_FIR_CTL1_BURSTEN;
+ //*pREG_FIR0_CTL1 = BITM_FIR_CTL1_EN|BITM_FIR_CTL1_DMAEN|(firHead.num -1)<<BITP_FIR_CTL1_CH|BITM_FIR_CTL1_BURSTEN;
+ *pREG_FIR0_CTL1 = BITM_FIR_CTL1_EN|BITM_FIR_CTL1_DMAEN|((firHead.num -1)<<BITP_FIR_CTL1_CH);
firHead.status = acc_processing;
}
diff --git a/drv/board.c b/drv/board.c
index c638f50..557156a 100644
--- a/drv/board.c
+++ b/drv/board.c
@@ -19,6 +19,9 @@
#include "linkport.h"
+unsigned int SAMPLE_RATE = 48000;
+unsigned int SAMPLE_NUM = 64;
+
void spu_config(void)
{
@@ -223,7 +226,7 @@
if(sports[i].interrupt) {
dma_install_interrupt(sports[i].spid);
}
- sport_config(get_sport_regs(sports[i].spid) , &sports[i]);
+ sport_config(get_sport_regs(sports[i].spid) , &sports[i], SAMPLE_NUM);
}
}
diff --git a/drv/board.h b/drv/board.h
index 18e1b78..dfce4eb 100644
--- a/drv/board.h
+++ b/drv/board.h
@@ -5,8 +5,9 @@
* Author: graydon
*/
-#ifndef DRV_BOARD_H_
-#define DRV_BOARD_H_
+//#ifndef DRV_BOARD_H_
+//#define DRV_BOARD_H_
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -14,6 +15,10 @@
#include "typedefs.h"
#include "sru_dai.h"
+
+extern unsigned int SAMPLE_RATE;
+extern unsigned int SAMPLE_NUM;
+
/*
* 为了和21489 保持兼容, 协议定义全部采用short类型
* */
@@ -121,4 +126,4 @@
#ifdef __cplusplus
}
#endif
-#endif /* DRV_BOARD_H_ */
+//#endif /* DRV_BOARD_H_ */
diff --git a/drv/pwr.c b/drv/pwr.c
index a77dcb5..cd4161f 100644
--- a/drv/pwr.c
+++ b/drv/pwr.c
@@ -28,6 +28,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <services/pwr/adi_pwr.h>
+#include "DMCInit.h"
/**********************************************************************************************
* CGU Configuration Number 0
diff --git a/drv/spi.c b/drv/spi.c
index e51f1b5..2f30a48 100644
--- a/drv/spi.c
+++ b/drv/spi.c
@@ -7,12 +7,14 @@
#include <stdint.h>
#include <stdio.h>
#include <services/int/adi_int.h>
+#include <services/int/adi_sec.h>
+#include <drivers/spi/adi_spi.h>
#include <signal.h>
#include "typedefs.h"
#include "spi.h"
#include "gpio.h"
#include "config.h"
-#include <drivers/spi/adi_spi.h>
+
#define MASTER 0
#define CPHA 1
@@ -38,7 +40,7 @@
// GPIO_SetOutPut(GPIOA, GPIO_Pin12|GPIO_Pin13, GPIO_HIGH);
// GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_HIGH);
- GPIO_SetOutPut(GPIOA, GPIO_Pin13, GPIO_LOW);
+ GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_LOW);
SPIRxCnt ++ ;
SPIRxDone = 1;
@@ -64,7 +66,7 @@
*pREG_DMA26_CFG = (MSIZE<<8) | (PSIZE<<4) | 4 ;
*pREG_DMA26_XCNT = SPI_BUFFER_SIZE;
*pREG_DMA26_XMOD = 1;
- *pREG_DMA26_ADDRSTART= (uint32_t)SPI_Tx_BUFFER|MP_OFFSET;
+ *pREG_DMA26_ADDRSTART= (void *)((uint32_t)SPI_Tx_BUFFER|MP_OFFSET);
*pREG_DMA26_CFG |= 1 ;
*pREG_SPI2_TXCTL |= (1<<0);
@@ -74,7 +76,7 @@
*pREG_DMA27_CFG = (1<<1)| (MSIZE<<8) | (PSIZE<<4) | (1<<20) | 4 ;
*pREG_DMA27_XCNT = SPI_BUFFER_SIZE;
*pREG_DMA27_XMOD = 1;
- *pREG_DMA27_ADDRSTART= (uint32_t)SPI_Rx_BUFFER|MP_OFFSET;
+ *pREG_DMA27_ADDRSTART= (void *)((uint32_t)SPI_Rx_BUFFER|MP_OFFSET);
*pREG_DMA27_CFG |= 1 ;
*pREG_SPI2_RXCTL |= (1<<0);
@@ -90,13 +92,13 @@
*pREG_DMA26_CFG = (MSIZE<<8) | (PSIZE<<4) | 4 ;
*pREG_DMA26_XCNT = SPI_BUFFER_SIZE;
*pREG_DMA26_XMOD = 1;
- *pREG_DMA26_ADDRSTART= (uint32_t)SPI_Tx_BUFFER|MP_OFFSET;
+ *pREG_DMA26_ADDRSTART= (void *)((uint32_t)SPI_Tx_BUFFER|MP_OFFSET);
*pREG_DMA26_CFG |= 1 ;
*pREG_DMA27_CFG = (1<<1)| (MSIZE<<8) | (PSIZE<<4) | (1<<20) | 4 ;
*pREG_DMA27_XCNT = SPI_BUFFER_SIZE;
*pREG_DMA27_XMOD = 1;
- *pREG_DMA27_ADDRSTART= (uint32_t)SPI_Rx_BUFFER|MP_OFFSET;
+ *pREG_DMA27_ADDRSTART= (void *)((uint32_t)SPI_Rx_BUFFER|MP_OFFSET);
*pREG_DMA27_CFG |= 1 ;
*pREG_SPI2_CTL= (MASTER<<1)|(0<<3)|(CPHA<<4)|(CPOL<<5)|(1<<6)|(1<<8)|(BITS<<9)|(1<<0);
diff --git a/drv/sport.c b/drv/sport.c
index cb74950..bc1b6e9 100644
--- a/drv/sport.c
+++ b/drv/sport.c
@@ -49,7 +49,6 @@
void * buffer;
};
-unsigned int SAMPLE_NUM = 32;
static AudioCodec mAudioCodec[16];
static u32 mCodecNum = 0;
static struct DMA_Desc sp_desc[32];//0a_ping,0a_pong,0b_ping,0b_pong,...
@@ -68,14 +67,14 @@
return 0;
}
-void sport_config(volatile SportRegsDef* regs , struct SportDef * config)
+void sport_config(volatile SportRegsDef* regs , struct SportDef * config, unsigned int sample_num)
{
u32 i;
volatile DMARegsDef* dma = get_dma_regs(config->spid);
struct DMA_Desc* desca_0 = &sp_desc[config->spid*2 + 0];
struct DMA_Desc* desca_1 = &sp_desc[config->spid*2 + 1];
- u32 dmaBufferLen = config->slots*SAMPLE_NUM;
+ u32 dmaBufferLen = config->slots * sample_num;
s32* dmaBuffer_ping, *dmaBuffer_pong;
if(config->enable_sec) {
diff --git a/drv/sport.h b/drv/sport.h
index 0fc7296..61ef0fe 100644
--- a/drv/sport.h
+++ b/drv/sport.h
@@ -42,7 +42,7 @@
void sport_init(void);
volatile SportRegsDef* get_sport_regs(uint32_t sportid);
-void sport_config(volatile SportRegsDef* regs ,struct SportDef * config);
+void sport_config(volatile SportRegsDef* regs ,struct SportDef * config, unsigned int sample_num);
void sport_enable(volatile SportRegsDef* regs, ubool enable_sec);
#ifdef __cplusplus
}
diff --git a/inc/ModuleProAPI.h b/inc/ModuleProAPI.h
index 2fba2de..8a0437c 100644
--- a/inc/ModuleProAPI.h
+++ b/inc/ModuleProAPI.h
@@ -42,6 +42,7 @@
__MODULE_EXPORT IModule* SignalGeneraterCreate(u32 n, ubool linkEnable , u32 sampleRate, u32 sampleNum, u16 inputNum, u16 outputNum);
__MODULE_EXPORT IModule* ContinuousSPLCreate(u32 n, ubool linkEnable , u32 sampleRate, u32 sampleNum, u16 inputNum, u16 outputNum);
__MODULE_EXPORT IModule* DummyCreate(u32 n, ubool linkEnable , u32 sampleRate, u32 sampleNum, u16 inputNum, u16 outputNum);
+__MODULE_EXPORT IModule* SignalSourceCreate(u32 n, ubool linkEnable , u32 sampleRate, u32 sampleNum, u16 inputNum, u16 outputNum);
__MODULE_EXPORT IModule* InputCreate(u32 n,ubool linkEnable , u32 sampleRate, u32 sampleNum, u16 inputNum, u16 outputNum);
__MODULE_EXPORT IModule* GainCreate(u32 n, ubool linkEnable , u32 sampleRate, u32 sampleNum, u16 inputNum, u16 outputNum);
__MODULE_EXPORT IModule* OutputCreate(u32 n, ubool linkEnable , u32 sampleRate, u32 sampleNum, u16 inputNum, u16 outputNum);
diff --git a/inc/config.h b/inc/config.h
index 490d6bd..aae15e0 100644
--- a/inc/config.h
+++ b/inc/config.h
@@ -1,13 +1,18 @@
-#ifndef CORE_CONFIG_H_
-#define CORE_CONFIG_H_
+//#ifndef CORE_CONFIG_H_
+//#define CORE_CONFIG_H_
+
+//#pragma once
+
+#include "../drv/board.h"
//全局宏定义.
#define MP_OFFSET 0x28000000
#define SPI_BUFFER_SIZE (1024)
-#define SAMPLE_RATE 48000
+//#define SAMPLE_RATE 48000
//process block sample size.
-extern unsigned int SAMPLE_NUM;
+//extern unsigned int SAMPLE_RATE;
+//extern unsigned int SAMPLE_NUM;
//f2f.c use physical input & output
#define PHY_INPUT_NUM 64
@@ -15,6 +20,8 @@
#define LEVEL_REPORT_TIME(x) \
(x*SAMPLE_RATE/(1000*SAMPLE_NUM))
-#endif
+
+
+//#endif
diff --git a/lib/ModuleProcLibs.dlb b/lib/ModuleProcLibs.dlb
index 7841d1f..0948ad9 100644
--- a/lib/ModuleProcLibs.dlb
+++ b/lib/ModuleProcLibs.dlb
Binary files differ
diff --git a/lib/aer.dlb b/lib/aer.dlb
index 6805033..d2c7c0b 100644
--- a/lib/aer.dlb
+++ b/lib/aer.dlb
Binary files differ
diff --git a/sch/dsp-21569_V1.pdf b/sch/dsp-21569_V1.pdf
new file mode 100644
index 0000000..bff661d
--- /dev/null
+++ b/sch/dsp-21569_V1.pdf
Binary files differ
diff --git "a/sch/\345\244\251\345\256\253DSP\346\221\230\350\256\260.docx" "b/sch/\345\244\251\345\256\253DSP\346\221\230\350\256\260.docx"
new file mode 100644
index 0000000..1adb4ac
--- /dev/null
+++ "b/sch/\345\244\251\345\256\253DSP\346\221\230\350\256\260.docx"
Binary files differ
diff --git a/src/ModuleExport.cpp b/src/ModuleExport.cpp
index 7b16d4f..2114d46 100644
--- a/src/ModuleExport.cpp
+++ b/src/ModuleExport.cpp
@@ -19,16 +19,17 @@
ModuleProcessLibInit();
if (modules.empty()) {
- modules.push_back(ModuleEntry("Input",ModuleType::PROC_INPUT, InputCreate, ufalse));
+ modules.push_back(ModuleEntry("Input", ModuleType::PROC_INPUT, SignalSourceCreate, ufalse)); //SignalSource
+// modules.push_back(ModuleEntry("Input",ModuleType::PROC_INPUT, InputCreate, ufalse));
modules.push_back(ModuleEntry("Output",ModuleType::PROC_OUTPUT, OutputCreate, ufalse));
- modules.push_back(ModuleEntry("Meter",ModuleType::PROC_METER, MeterCreate, ufalse));
+ modules.push_back(ModuleEntry("Meter",ModuleType::PROC_METER, MeterCreate, utrue));
modules.push_back(ModuleEntry("Expander",ModuleType::PROC_EXPANDER, ExpanderCreate, utrue));
modules.push_back(ModuleEntry("Compress",ModuleType::PROC_COMPRESS, CompressorCreate, utrue));
modules.push_back(ModuleEntry("Limiter",ModuleType::PROC_LIMIT, LimiterCreate, utrue));
modules.push_back(ModuleEntry("Mixer",ModuleType::PROC_MIXER, MixerCreate, ufalse));
modules.push_back(ModuleEntry("Delay",ModuleType::PROC_DELAY, DelayCreate, utrue));
- modules.push_back(ModuleEntry("Gain",ModuleType::PROC_GAIN, GainCreate, ufalse));
+ modules.push_back(ModuleEntry("Gain",ModuleType::PROC_GAIN, GainCreate, utrue));
modules.push_back(ModuleEntry("GainSharingmixer",ModuleType::PROC_AUTOMIXER, GSAMCreate, ufalse));
modules.push_back(ModuleEntry("GatingMixer",ModuleType::PROC_GATING_AUTOMIXER, GatingAMCreate, ufalse));
modules.push_back(ModuleEntry("SPL",ModuleType::PROC_CONTINUNOUS_SPL, ContinuousSPLCreate, utrue));
@@ -36,19 +37,19 @@
modules.push_back(ModuleEntry("Ducker",ModuleType::PROC_DUCKER, DuckerCreate, utrue));
modules.push_back(ModuleEntry("AGC",ModuleType::PROC_AGC, AGCCreate, utrue));
modules.push_back(ModuleEntry("SELECTOR",ModuleType::PROC_SELECTOR, MixerCreate, ufalse));
- modules.push_back(ModuleEntry("SignalGenerator",ModuleType::PROC_SIGNALGEN, SignalGeneraterCreate, ufalse));
+ modules.push_back(ModuleEntry("SignalGenerator",ModuleType::PROC_SIGNALGEN, SignalGeneraterCreate, utrue));
modules.push_back(ModuleEntry("GATING",ModuleType::PROC_GATING, NoiseGateCreate,utrue));
modules.push_back(ModuleEntry("ROUTE",ModuleType::PROC_ROUTE, RouteCreate,ufalse));
modules.push_back(ModuleEntry("EQ",ModuleType::PROC_EQ, EQsCreate, utrue));
modules.push_back(ModuleEntry("GEQ",ModuleType::PROC_GEQ, GEQCreate, utrue));
- modules.push_back(ModuleEntry("Crossover",ModuleType::PROC_CROSSOVER, CrossOverCreate, ufalse));
+ modules.push_back(ModuleEntry("Crossover",ModuleType::PROC_CROSSOVER, CrossOverCreate, utrue));
modules.push_back(ModuleEntry("nhs",ModuleType::PROC_FEEDBACK, NHSCreate, utrue));
- modules.push_back(ModuleEntry("aec",ModuleType::PROC_AEC, SQECreate, utrue));
+ modules.push_back(ModuleEntry("aec",ModuleType::PROC_AEC, SQECreate, ufalse));
modules.push_back(ModuleEntry("ans",ModuleType::PROC_ANS, ANSCreate, utrue));
modules.push_back(ModuleEntry("Sysctrl",ModuleType::PROC_SYSCTL, SysctlCreate, ufalse));
modules.push_back(ModuleEntry("FIR",ModuleType::PROC_FIR, FIRCreate,utrue));
//modules.push_back(ModuleEntry("AFC",ModuleType::PROC_AFC, AFCCreate, utrue));
- modules.push_back(ModuleEntry("Pitch",ModuleType::PROC_PITCH, PitchCreate, ufalse));
+ modules.push_back(ModuleEntry("Pitch",ModuleType::PROC_PITCH, PitchCreate, utrue));
modules.push_back(ModuleEntry("Reverb",ModuleType::PROC_REVERB, ReverbCreate, utrue));
modules.push_back(ModuleEntry("Echo",ModuleType::PROC_ECHO, EchoCreate, utrue));
modules.push_back(ModuleEntry("DummyInput",ModuleType::DUMMY_INPUT, DummyCreate, ufalse));
diff --git a/src/ModuleExport.h b/src/ModuleExport.h
index 7d041e7..1b3889a 100644
--- a/src/ModuleExport.h
+++ b/src/ModuleExport.h
@@ -19,33 +19,33 @@
PROC_METER, //电平表
PROC_EQ, //EQ
PROC_EXPANDER, //扩展器
- PROC_COMPRESS, //压缩器
+ PROC_COMPRESS, //压缩器 5
PROC_LIMIT, //限幅器
PROC_MIXER, //混音器
PROC_DELAY, //延时器
PROC_CROSSOVER, //分频器
- PROC_OUTPUT, //输出
+ PROC_OUTPUT, //输出 10
PROC_GAIN, //增益
PROC_FEEDBACK, //陷波反馈抑制
PROC_AUTOMIXER, //增益共享自动混音
PROC_AGC, //自动增益
- PROC_AEC, //回声消除
+ PROC_AEC, //回声消除 15
PROC_ANS, //噪声抑制
PROC_SYSCTL, //系统控制
PROC_SHELF, // 高低架
PROC_SELECTOR, //混音器
- PROC_GATING_AUTOMIXER, //门限自动混音
- PROC_CONTINUNOUS_SPL, //连续型SPL
+ PROC_GATING_AUTOMIXER, //门限自动混音 20
+ PROC_CONTINUNOUS_SPL, //连续型SPL(噪声增益补偿)
PROC_GATING, //噪声门
PROC_DUCKER, //闪避器
PROC_REVERB, //混响
- PROC_ECHO, //回声
+ PROC_ECHO, //回声 25
PROC_GEQ, //图形均衡器
PROC_FIR, //FIR滤波器
PROC_AFC, //自适应反馈抑制器
PROC_SIGNALGEN, //信号发生器
- PROC_PITCH, //变音器
+ PROC_PITCH, //变音器 30
PROC_ROUTE, //路由器
DUMMY_INPUT,
@@ -59,7 +59,7 @@
public:
//s8 name[16];
u16 module_type;
- ubool link_enable;
+ ubool link_enable; //参数多通道共享支持,
ubool pad =0;
Create module_create;
diff --git a/src/f2f.c b/src/f2f.c
index 332b850..0dcba12 100644
--- a/src/f2f.c
+++ b/src/f2f.c
@@ -1,4 +1,5 @@
#include <string.h>
+#include <math.h>
#include "config.h"
#include "f2f.h"
#include "../drv/sport.h"
@@ -128,8 +129,38 @@
}
}
+
+void in2out_bypass(ufloat* out[], ufloat* in[], int ch, int len)
+{
+ int i, j;
+ for (i = 0; i < ch; i++)
+ for (j = 0; j < len; j++) {
+ out[i][j] = in[i][j];
+ }
+}
+void sin_gen(ufloat* dat, int len)
+{
+ static int sta = 0;
+ for (u32 i = 0; i < len; i++) {
+ dat[i] = 0.4f * sinf(2 * 3.1415926f * 675 * sta++ / SAMPLE_RATE);
+ }
+ if (sta == SAMPLE_RATE)
+ sta = 0;
+}
uvoid UpdateOutput(u32 iid ,u32 blockIndex)
{
+// in2out_bypass(mTxChannel[0], mRxChannel[0], 1, SAMPLE_NUM);
+// static ufloat data[64] = {0};
+// static int odd = 0;
+// if (0 == odd++ % 3) {
+// sin_gen(data, SAMPLE_NUM);
+// for (u32 i = 0; i < SAMPLE_NUM; i++) {
+// for (u32 j = 0; j < 8; j++) {
+// mTxChannel[0][j][i] = data[i];
+// }
+// }
+// }
+
for(s32 type =0 ; type < COUNT ;type ++) {
u16 channel = 0;
u16 output_num = mOutputNum[type];
@@ -138,6 +169,7 @@
for(u32 i =0 ;i < gCodecNum[type] ;i++) {
const AudioCodec* codec = &codec_arr[i];
+
if(codec->rx == utrue) continue;
ubool enable = (iid == codec->follow_intr_no);
@@ -145,8 +177,10 @@
if(codec->enable_sec){
for(u32 j = 0; channel < output_num && j < codec->channel_num*2 ;j ++,channel++) {
- if(enable && pTxChannel[channel] != NULL)
- fixData(dataPtr +OFFSET(j), pTxChannel[channel], codec->slot_num*2, SAMPLE_NUM);
+ if(enable && pTxChannel[channel] != NULL) {
+ s32 shift = OFFSET(j);
+ fixData(dataPtr + shift, pTxChannel[channel], codec->slot_num*2, SAMPLE_NUM);
+ }
}
}
else{
diff --git a/src/frames.cpp b/src/frames.cpp
index 44fb329..5f46a1c 100644
--- a/src/frames.cpp
+++ b/src/frames.cpp
@@ -30,9 +30,9 @@
Frames::Frames(int num)
{
- frameList = (Frame*)sram_malloc(SRAM_AUTO,mem_any, num*sizeof(Frame));
+ frameList = (Frame*)sram_malloc(SRAM_AUTO, mem_any, num*sizeof(Frame));
//分配连续内存.
- dataPtr = (ufloat*)sram_malloc(SRAM_AUTO,mem_any ,num*SAMPLE_NUM*sizeof(float));
+ dataPtr = (ufloat*)sram_malloc(SRAM_AUTO, mem_any, num*SAMPLE_NUM*sizeof(float));
assert(dataPtr != NULL);
for (int i = 0; i < num; i++) {
diff --git a/src/hw_adapter.h b/src/hw_adapter.h
index dfe31d2..d7c03f2 100644
--- a/src/hw_adapter.h
+++ b/src/hw_adapter.h
@@ -29,31 +29,41 @@
s8 ana_input_num ;
s8 ana_output_num ;
+ s8 usb_input_num;
+ s8 usb_output_num;
s8 dante_input_num ;
s8 dante_output_num ;
+ s8 local_input_num;
+ s8 local_output_num;
public:
virtual ~hw_adapter_t(){}
- hw_adapter_t(s8 dual_dsp,s8 dsp_index,s8 ana_input_num,s8 ana_output_num,s8 dante_input_num,s8 dante_output_num)
+ hw_adapter_t(s8 dual_dsp, s8 dsp_index, s8 local_input_num, s8 local_output_num, s8 dante_input_num, s8 dante_output_num)
{
this->dual_dsp = dual_dsp;
this->dsp_index = dsp_index ;
- this->ana_input_num = ana_input_num;
- this->ana_output_num = ana_output_num;
+ this->local_input_num = local_input_num;
+ this->local_output_num = local_output_num;
this->dante_input_num = dante_input_num;
this->dante_output_num = dante_output_num;
+ this->usb_input_num = 2;
+ this->usb_output_num = 2;
+ this->ana_input_num = local_input_num - usb_input_num;
+ this->ana_output_num = local_output_num - usb_output_num;
}
- uvoid get_channel_num(s8* ana_rx_num,s8* ana_tx_num,s8* dante_rx_num,s8* dante_tx_num)
+ uvoid get_channel_num(s8* loc_rx_num,s8* loc_tx_num,s8* dante_rx_num,s8* dante_tx_num,s8* usb_rx_num,s8* usb_tx_num)
{
- *ana_rx_num = ana_input_num;
- *ana_tx_num = ana_output_num;
+ *loc_rx_num = local_input_num;
+ *loc_tx_num = local_output_num;
*dante_rx_num = dante_input_num;
*dante_tx_num = dante_output_num;
+ *usb_rx_num = usb_input_num;
+ *usb_tx_num = usb_output_num;
}
uvoid get_channel_num(u16* input_num ,u16* output_num)
{
- *input_num = ana_input_num+dante_input_num;
- *output_num = ana_output_num+dante_output_num;
+ *input_num = local_input_num+dante_input_num;
+ *output_num = local_output_num+dante_output_num;
}
s32 get_dsp_index() {return dsp_index ;}
diff --git a/src/main.cpp b/src/main.cpp
index 3a527de..876ea9d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,6 +26,9 @@
#include "queue.h"
#include "f2f.h"
#include "var_state.h"
+#include "tob.h"
+#include "tg/module_def.h"
+#include "tg/tg_scene.h"
//全局变量
#define MAX_INTR 100
@@ -47,6 +50,7 @@
GPIO_SetOutPut(GPIOB, GPIO_Pin10, level);
}
+
/*
* 128 路
UpdateInput && UpdateOutput 7.37%
@@ -54,20 +58,25 @@
* */
extern "C" uvoid AudioProcCallBack (u32 iid)
{
- //ToB* tob = ToB::GetInstance();
+ ToB* tob = ToB::GetInstance();
ufloat clock_start,clock_stop;
VarState& var = VarState::GetInstance();
- //if(tob == NULL) return ;
+ if(var.master_intr == iid){
+ var.dsp_status = DSPStatus::dsp_running_ok;
+ }
+ if(tob == NULL) return ;
if(var.TopoLoading){
MuteOutput();
- } else if(var.master_intr == iid){
+ }
+ else if(var.master_intr == iid){
clock_start = clock();
UpdateInput(iid, DMACount[iid]&0x1);
- //tob->toProc();
+ tob->toProc();
+
UpdateOutput(iid, DMACount[iid]&0x1);
- //LP_transmit();
+// LP_transmit();
ModulesAsynSetInterval(proc_secs);
fir_acc_startup();
clock_stop = clock();
@@ -77,7 +86,8 @@
UpdateInput(iid, DMACount[iid]&0x1);
UpdateOutput(iid, DMACount[iid]&0x1);
}
- DMACount[iid]++;
+
+ ++DMACount[iid];
}
int main(int argc, char *argv[])
@@ -109,19 +119,22 @@
memset(DMACount, 0, sizeof(DMACount));
Message* spiMsg = new Message(8);
- //第一次启动上报特别是仿真的时候需要arm'重新发送消息.
- spiMsg->DspStatusPush(DSP_EMULATE_DEBUG, 0, 0);
- spiMsg->ReportDspStatus(&msg);
SPI2_Init();
fir_acc_init();
//通知arm启动完成.
- //dir: pin12, High level DSP can receive data, low level DSP has data to send .
- //busy: pin13, low level DSP is in busy state and cannot receive and send data, high level is free.
+ //dir: pin12, High level DSP can receive data, low level DSP has data toz send .
+ //busy: pin13/PB5, low level DSP is in busy state and cannot receive and send data, high level is free.
GPIO_SetOutPut(GPIOA, GPIO_Pin12, GPIO_HIGH);
- GPIO_SetOutPut(GPIOA, GPIO_Pin13, GPIO_HIGH);
+ GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_HIGH);
+
+ //第一次启动上报特别是仿真的时候需要arm'重新发握手.
+ spiMsg->DspStatusPush(DSP_EMULATE_DEBUG, 0, 0);
+ spiMsg->ReportDspStatus(&msg);
+
+ printf("free sram %d, L2 %d\n", sram_free_space(SRAM_DDR, mem_any), sram_free_space(SRAM_L2, mem_any));
while(1) {
asyn_proc_secs = ModulesAsynProcess();
@@ -134,11 +147,11 @@
ledCount = DMACount[var.master_intr];
cpu = cpu_utility()*100; //all modules execute time.;
- mem = (1- space_unused()/total_mem)*10000;
+ mem = (1.0f - (float)space_unused()/total_mem)*10000;
spiMsg->DspStatusPush(DSP_MEM_UTILITY, &mem, 1);
spiMsg->DspStatusPush(DSP_CPU_UTILITY, &cpu, 1);
- spiMsg->DspStatusPush(DSP_CLOCK_STATUS,&var.dsp_status ,1);
+ spiMsg->DspStatusPush(DSP_RUNNING_STATUS,&var.dsp_status ,1);
spiMsg->ReportDspStatus(&msg);
}
@@ -157,23 +170,28 @@
//clock state will change after running,it need check always.
//about 1s
- if(++loop_cnt > 100000000){
- if(clock_check_count == DMACount[var.master_intr]) {
+ if(++loop_cnt > 5e+6){
+ if (var.clock_ok && clock_check_count == DMACount[var.master_intr]) {
var.dsp_status = dsp_no_clock;
- spiMsg->DspStatusPush(DSP_CLOCK_STATUS,&var.dsp_status ,1);
+ spiMsg->DspStatusPush(DSP_RUNNING_STATUS, &var.dsp_status ,1);
spiMsg->ReportDspStatus(&msg);
+ printf("clk0 ok\n");
}
loop_cnt =0;
clock_check_count = DMACount[var.master_intr];
+// printf("clk1 ok\n");
}
-
if(!var.clock_ok && var.dsp_status == DSPStatus::dsp_running_ok && var.HandShakeSuccesful) {
//notify arm to work normaly.
- spiMsg->DspStatusPush(DSP_CLOCK_STATUS, 0, 0);
+ spiMsg->DspStatusPush(DSP_CLOCK_STATUS, &var.dsp_status, 1);
request_topo_count = DMACount[var.master_intr] ;
var.clock_ok = utrue;
+ spiMsg->ReportDspStatus(&msg);
+ printf("clk2 ok\n");
}
+
+
}
}
diff --git a/src/messageproc.cpp b/src/messageproc.cpp
index 38f0bd3..ae301d5 100644
--- a/src/messageproc.cpp
+++ b/src/messageproc.cpp
@@ -1,7 +1,7 @@
/*
* messageproc.c
*
- * Created on: 2021年11月1日
+ * Created on: 2021骞�1鏈�鏃� * Author: graydon
*/
#include <string.h>
@@ -10,7 +10,7 @@
#include "messageproc.h"
#include "../drv/spi.h"
#include "../drv/gpio.h"
-#include "../drv/memory.h"
+
#include "F2F.h"
#include "ModuleProAPI.h"
#include "tg/tg_adapter.h"
@@ -34,9 +34,44 @@
uvoid Message::ReportDspStatus(MSG* pmsg)
{
- s32 size = dsp_status_q.get_device_status_ptr(pmsg->data,MSG_DATA_LEN);
+ s32 size = dsp_status_q.get_device_status_ptr(pmsg->data, MSG_DATA_LEN);
if(size > 0) {
pmsg->Enc(MsgType::MSG_DSP_STATUS_REPORT, 0, size);
+ txQueue->Push(*pmsg);
+ }
+}
+
+uvoid Message::ReportLevel(MSG* pmsg)
+{
+ int i;
+ int data_len;
+
+ ToB* tob = ToB::GetInstance();
+ u16 LevelCnt = tob->GetLevels(Levels); //918 levels
+ u32 msgLen = LevelCnt * sizeof(*Levels);
+ int Packegs = (msgLen+MSG_DATA_LEN-1)/MSG_DATA_LEN;
+
+ pmsg->magic = 0x5aa5;
+// pmsg->dataLen = LevelCnt;
+ pmsg->totalPkts = Packegs;
+// pmsg->pktNo = 1;
+ pmsg->msgType = MSG_GET_LEVEL;
+ pmsg->msgID = LevelCnt;
+
+ // Split packeg
+ for(i=0; i<Packegs; i++){
+ if(i == Packegs-1){
+ data_len = msgLen - i * MSG_DATA_LEN;
+ }
+ else{
+ data_len = MSG_DATA_LEN;
+ }
+
+ memcpy(pmsg->data, Levels + i * MSG_DATA_LEN / sizeof(*Levels), data_len);
+ pmsg->dataLen = data_len;
+ pmsg->pktNo = i;
+
+ pmsg->Enc(MsgType::MSG_GET_LEVEL, 0, data_len);
txQueue->Push(*pmsg);
}
}
@@ -56,19 +91,20 @@
if(tob != NULL && pmsg->pktNo == pmsg->totalPkts - 1) {
VarState& var = VarState::GetInstance();
- u32 type = tob->GetModuleType(ptr->mid);
+// u32 type = tob->GetModuleType(ptr->mid);
s32 data_num = (pmsg->totalPkts-1)*MSG_DATA_LEN+pmsg->dataLen;
s16* data = (s16*)(ptr + 1);
data_num = (data_num - sizeof(struct ParamCtrl))/sizeof(s16);
-
- ptr->mid = var.pscene->get_module_id(ptr->mid, type, ptr->cmd) ;
+// ptr->mid = var.pscene->get_module_id(ptr->mid, type, ptr->cmd) ;
+// printf("mID:%d pID:%d val[0]:%d val[1]:%d\n",ptr->mid, ptr->cmd, data[0], data[1]);
tob->toCtrl(ptr->mid, ptr->cmd, data, data_num);
}
return 0;
}
+
s32 Message::PresetProcess(MSG* pmsg)
{
@@ -79,12 +115,15 @@
sram_free(SRAM_DDR, bin);
bin = NULL;
}
+
if(pmsg->pktNo == 0 && bin == NULL) {
- bin = (u8*)sram_malloc(SRAM_DDR, mem_any ,pmsg->totalPkts*MSG_DATA_LEN);
+ bin = (u8*)sram_malloc(SRAM_DDR, mem_any, pmsg->totalPkts*MSG_DATA_LEN);
}
if(bin == NULL) return -1;
+// printf("No:%d len %d\n", pmsg->pktNo,pmsg->dataLen);
var.TopoLoading = utrue;
memcpy(bin+pmsg->pktNo*MSG_DATA_LEN, pmsg->data , pmsg->dataLen);
+
if(pmsg->pktNo == pmsg->totalPkts -1) {
u32 size = (pmsg->totalPkts -1)*MSG_DATA_LEN+pmsg->dataLen;
@@ -100,21 +139,22 @@
var.TopoStatus = PRESET_STA::PRESET_ERR;
}
else if(tob){
- s8* content = (s8*)sram_malloc(SRAM_DDR, mem_any ,16*1024);
+ int preset_size = sizeof(tag_parameters); // 45128 + sizeof(tag_fir) * MAX_OUTPUT_NUM; // size + FIR
+ u8* content = (u8*)sram_malloc(SRAM_DDR, mem_any, preset_size);
s32 size ;
+
+ tob->toClear();
var.pscene->update_module();
size = var.pscene->convert_to_bin(content);
-
- tob->toClear();
- tob->toAnalysis(bin, size);
+ tob->toAnalysis(content, size);
sram_free(SRAM_DDR, content);
var.TopoStatus = PRESET_STA::PRESET_DONE;
}
}
sram_free(SRAM_DDR, bin); bin = NULL;
- var.TopoLoading =0 ;
+ var.TopoLoading = ufalse ;
}
return 0;
@@ -122,24 +162,27 @@
s32 Message::HandshakeMessageProcess(MSG* pmsg)
{
+// s8 usb_rx_ch=2, usb_tx_ch=2;
VarState& var = VarState::GetInstance();
ptag_device_config device_config = (ptag_device_config)pmsg->data;
struct DSPConfig dspconfig ;
if(var.HandShakeSuccesful == ufalse) {
- //可以根据ptag_device_config.hardware_type动态适配型号.
+ //鍙互鏍规嵁ptag_device_config.hardware_type鍔ㄦ�閫傞厤鍨嬪彿.
if(var.pscene){
delete var.pscene;
var.pscene = NULL;
}
- hw_adapter_t* _adapter = new tg_hw_adapter_t(device_config->dual_dsp,device_config->dsp_index
- ,device_config->local_rx_num,device_config->local_tx_num
- ,device_config->dante_rx_num,device_config->dante_tx_num);
- var.pscene = new tgScene(_adapter);
+// param_init(device_config);
+ hw_adapter_t* _adapter = new tg_hw_adapter_t(device_config->dual_dsp, device_config->dsp_index
+ ,device_config->local_rx_num, device_config->local_tx_num
+ ,device_config->dante_rx_num, device_config->dante_tx_num);
+ var.pscene = new(SRAM_DDR) tgScene(_adapter);
_adapter->config_board(&dspconfig);
+ new(SRAM_DDR) ToB(device_config->dual_dsp, device_config->dsp_index);
SAMPLE_NUM = dspconfig.mSampleNum;
var.master_intr = dspconfig.mIntrNo;
@@ -147,9 +190,9 @@
ModuleLeveldBUSetting(dspconfig.mConvertUnit);
//Config(conf);
- RouteConfig(dspconfig.routes,dspconfig.mRouteNum);
+ RouteConfig(dspconfig.routes, dspconfig.mRouteNum);
SRCsConfig(0 , &dspconfig.srcs[0]);
- SRCsConfig(1 , &dspconfig.srcs[4]);
+ SRCsConfig(1 , &dspconfig.srcs[1]);
PCGsConfig(dspconfig.pcgs);
SportsConfig(dspconfig.sports);
//LinportConfig(dspconfig.linkport);
@@ -158,7 +201,7 @@
}
Send(MsgType::MSG_ACK_REQ, 0 , 0);
-
+ printf("HandShake OK\n");
return 0;
}
@@ -175,6 +218,7 @@
ParamCtrl(pmsg);
break;
case MsgType::MSG_GET_LEVEL:
+ ReportLevel(pmsg);
break;
case MsgType::MSG_PARAM_CONFIG:
case MsgType::MSG_PARAM_COMPLETED:
@@ -195,6 +239,14 @@
uvoid Message::Proc()
{
u32 status = 0;
+// static bool bSetOk = 0;
+
+// MSG* p = (MSG*)SPI_Rx_BUFFER;
+// if (0 == bSetOk) {
+// HandshakeMessageProcess(p); //virtual communication
+// PresetProcess(p);
+// bSetOk = 1;
+// }
if(SPIRxDone) {
RxMessageHandler((MSG*)SPI_Rx_BUFFER);
@@ -207,6 +259,6 @@
GPIO_SetOutPut(GPIOA, GPIO_Pin12, GPIO_HIGH);
}
SPI2_SetTransMode(SPIStatus::SPI_TRX);
- GPIO_SetOutPut(GPIOA, GPIO_Pin13, GPIO_HIGH);
+ GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_HIGH);
}
}
diff --git a/src/messageproc.h b/src/messageproc.h
index 4c904c9..4eeb767 100644
--- a/src/messageproc.h
+++ b/src/messageproc.h
@@ -9,16 +9,19 @@
#define MESSAGEPROC_H_
#include <stdint.h>
+#include <heapnew>
#include "protocol.h"
#include "typedefs.h"
#include "queue.h"
#include "dsp_report.h"
+#include "../drv/memory.h"
class Message{
private:
Queue<MSG>* txQueue;
ReportStatus dsp_status_q;
+ s16* Levels;
s32 PresetProcess(MSG* pmsg);
@@ -27,10 +30,14 @@
s32 HandshakeMessageProcess(MSG* pmsg);
s32 RxMessageHandler(MSG* pmsg);
+
+ void param_init(ptag_device_config pDevCfg);
+
public:
Message(u32 num)
{
txQueue = new Queue<MSG>(num);
+ Levels = new s16[1000];
}
~Message()
{
@@ -48,6 +55,7 @@
uvoid Proc();
uvoid ReportDspStatus(MSG* pmsg);
+ uvoid ReportLevel(MSG* pmsg);
};
#endif /* MESSAGEPROC_H_ */
diff --git a/src/param_ctrl.h b/src/param_ctrl.h
index 88aa16b..35046d0 100644
--- a/src/param_ctrl.h
+++ b/src/param_ctrl.h
@@ -14,7 +14,7 @@
//预设参数解析用
typedef u32 (*ParamCtrl_fn)(IModule* m, void* handle, int &plen);
//参数控制用
-typedef u32 (*Ctrl_fn)(IModule* m, u32 pID, s16* val_c);
+typedef u32 (*Ctrl_fn)(IModule* m, u32 pID, s16* val_c, u32 num);
class ParamEntry {
private:
@@ -23,11 +23,11 @@
Ctrl_fn ctrl;
public:
- ParamCtrl_fn GetParamEntry(){
+ ParamCtrl_fn GetParamEntry() const {
return param;
}
- Ctrl_fn GetCtrlEntry(){
+ Ctrl_fn GetCtrlEntry() const {
return ctrl;
}
ParamEntry() : param(nullptr), ctrl(nullptr) {}
@@ -39,6 +39,39 @@
};
class param_ctrl_t{
+protected:
+ std::map<u32, ParamEntry> mctrl_list;
+
+public:
+ // 返回pair避免重复查找
+ std::pair<ParamCtrl_fn, Ctrl_fn> GetEntries(u32 mtype) const
+ {
+ auto it = mctrl_list.find(mtype);
+ if(it != mctrl_list.end()) {
+ return {it->second.GetParamEntry(), it->second.GetCtrlEntry()};
+ }
+ return {nullptr, nullptr};
+ }
+
+ ParamCtrl_fn GetParamEntry(u32 mtype) const
+ {
+ auto it = mctrl_list.find(mtype);
+ return (it != mctrl_list.end()) ? it->second.GetParamEntry() : nullptr;
+ }
+
+ Ctrl_fn GetCtrlEntry(u32 mtype) const
+ {
+ auto it = mctrl_list.find(mtype);
+ return (it != mctrl_list.end()) ? it->second.GetCtrlEntry() : nullptr;
+ }
+
+ // 检查是否存在
+ bool HasEntry(u32 mtype) const
+ {
+ return mctrl_list.find(mtype) != mctrl_list.end();
+ }
+};
+/*class param_ctrl_t{
protected:
std::map<u32, ParamEntry> mctrl_list;
public:
@@ -55,9 +88,9 @@
if(mctrl_list.count(mtype))
return mctrl_list[mtype].GetCtrlEntry();
else
- return NULL;
+ return NULL;
}
-};
+};*/
diff --git a/src/protocol.h b/src/protocol.h
index 501da1c..69033b7 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -8,6 +8,7 @@
#ifndef PROTOCOL_H_
#define PROTOCOL_H_
+#include <string>
#include "config.h"
#define MSG_DATA_LEN (SPI_BUFFER_SIZE-16)
@@ -79,7 +80,7 @@
typedef struct{
short dual_dsp;
short dsp_index;
- short local_rx_num;
+ short local_rx_num; // include analog + usb channel
short local_tx_num;
short dante_rx_num;
short dante_tx_num;
diff --git a/src/protocol_internal.h b/src/protocol_internal.h
index 6e5914a..93de377 100644
--- a/src/protocol_internal.h
+++ b/src/protocol_internal.h
@@ -22,8 +22,7 @@
}PhyPort;
struct FlowChartHead {
- short crcLsb;
- short crcMsb;
+ int crc;
unsigned short module_num;
unsigned char compress;
unsigned char version;
diff --git a/src/scene.cpp b/src/scene.cpp
index e0cf1b2..e8618b9 100644
--- a/src/scene.cpp
+++ b/src/scene.cpp
@@ -4,6 +4,7 @@
* Created on: 2025年7月21日
* Author: 86189
*/
+#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include "config.h"
@@ -13,8 +14,9 @@
#include "protocol_internal.h"
#include "moduleexport.h"
#include "crc.h"
+#include "../drv/memory.h"
-s32 Scene::str_delim(const s8* str, u8 logic_channel[])
+s32 Scene::str_delim(const s8* str, u16 logic_channel[])
{
s8 pstr[32];
s8 * ptr;
@@ -30,7 +32,8 @@
ptr = strtok(NULL, "-");
end = atoi(ptr);
- while (start<=end)
+ if(start==end) return 0;
+ while (start <= end)
{
logic_channel[i++] = start++;
}
@@ -49,24 +52,27 @@
-s32 Scene::convert_to_bin(s8* bin)
+s32 Scene::convert_to_bin(u8* bin)
{
s32 i ,j;
struct FlowChartHead* flowchart = (struct FlowChartHead*)bin;
u32 size = sizeof(struct FlowChartHead);
s32 ninports,noutports;
- u8 rxBufID[64],txBufID[64];
+ u16 rxBufID[64],txBufID[64];
+ u32 dsp_index ;
u16 dsp_input_num[2] ={0,0};
u16 dsp_output_num[2] ={0,0};
s32 crc = 0xFFFFFFFF;
-
if (!bin) return 0;
+ struct Module *m = (struct Module *)(bin + size);
+ printf("proc list size %d\n", proc_list.size());
+
for (i=0; i< proc_list.size(); i++) {
- struct Module *m = (struct Module *)(bin + size);
- struct proc_field * p = &proc_list[i];
+ Module *m = (struct Module *)(bin + size);
+ proc_field * p = &proc_list[i];
ninports = str_delim(p->inportstr, rxBufID) ;
noutports = str_delim(p->outportstr , txBufID) ;
@@ -79,14 +85,14 @@
if(p->proc_type == PROC_DUCKER || p->proc_type == PROC_CONTINUNOUS_SPL) {
//insert a mixer.
struct Module *mixer = (struct Module *)(bin + size);
- u8 channelID[64];
+ u16 channelID[64];
mixer->mDsp = 0;
mixer->mID = p->proc_id + 320;
mixer->mType = ModuleType::PROC_MIXER;
mixer->mTag = 0;
mixer->mPhyModule = 0;
- mixer->mParamaddr = (s32)get_module_param_ptr(p->parameters,p->fixed);
+ mixer->mParamaddr = (s32)get_module_param_ptr(mixer->mType, p->parameters, p->fixed);
size += sizeof(struct Module);
@@ -95,53 +101,71 @@
mixer->mTxNum = 1;
memcpy(bin + size , &rxBufID[1], mixer->mTxNum*sizeof(u16)); size += mixer->mTxNum*sizeof(u16);
}
+ if(hw_adapter->get_system_is_dual_dsp()){
+ dsp_index = p->dsp_index ;
+ }
+ else {
+ dsp_index = 0;
+ }
+
m = (struct Module *)(bin + size);
for(j = 0 ; j< ninports ;j ++) {
- if(rxBufID[j] > dsp_input_num[p->dsp_index]) {
- dsp_input_num[p->dsp_index] = rxBufID[j];
+ if(rxBufID[j] > dsp_input_num[dsp_index]) {
+ dsp_input_num[dsp_index] = rxBufID[j];
}
}
for(j = 0 ; j< noutports ;j ++) {
- if(txBufID[j] > dsp_output_num[p->dsp_index]) {
- dsp_output_num[p->dsp_index] = txBufID[j];
+ if(txBufID[j] > dsp_output_num[dsp_index]) {
+ dsp_output_num[dsp_index] = txBufID[j];
}
}
- m->mDsp = 0;
+ m->mDsp = dsp_index;
m->mID = p->proc_id;
m->mType = p->proc_type;
m->mTag = p->tag;
m->mPhyModule = p->physic_type;
- m->mParamaddr = (s32)get_module_param_ptr(p->parameters,p->fixed);
+ m->mParamaddr = (s32)get_module_param_ptr(m->mType, p->parameters, p->fixed);
size += sizeof(struct Module);
m->mRxNum = ninports;
memcpy(bin + size , rxBufID, m->mRxNum*sizeof(u16)); size += m->mRxNum*sizeof(u16);
m->mTxNum = noutports;
memcpy(bin + size , txBufID, m->mTxNum*sizeof(u16)); size += m->mTxNum*sizeof(u16);
+
+ if(p->physic_type == ModuleInterfaceType::PHY_INPUT) {
+ PhyPort* phy_id = (PhyPort*)(bin + size);
+ for(j = 0 ; j< ninports ;j ++, phy_id++) {
+ phy_id->mIntType = 0;
+ phy_id->mPhyID = hw_adapter->get_physical_channel(1, rxBufID[j]-1);
+// printf("PhyID:%d\n", phy_id->mPhyID);
+ }
+ size += ninports*sizeof(PhyPort);
+ }
+ else if(p->physic_type == ModuleInterfaceType::PHY_OUTPUT){
+ PhyPort* phy_id = (PhyPort*)(bin + size);
+ for(j = 0 ; j< noutports ;j ++, phy_id++) {
+ phy_id->mIntType = 0;
+ phy_id->mPhyID = hw_adapter->get_physical_channel(0, txBufID[j]-1);
+ }
+ size += noutports*sizeof(PhyPort);
+ }
}
- ninports = dsp_input_num[0]>dsp_output_num[0]?dsp_input_num[0]:dsp_output_num[0];
- noutports = dsp_input_num[1]>dsp_output_num[1]?dsp_input_num[1]:dsp_output_num[1];
-
- if(0) {
- flowchart->dsp_buffer_num[0] = ninports;
- flowchart->dsp_buffer_num[1] = noutports;
- }
- else {
- flowchart->dsp_buffer_num[0] = ninports>noutports?ninports:noutports;
+ //dual_dsp for 2 DSP,else 1 DSP.
+ for (i =0 ;i < hw_adapter->get_system_is_dual_dsp() + 1 ;i ++) {
+ flowchart->dsp_buffer_num[i] = std::max(dsp_input_num[i], dsp_output_num[i]);
}
flowchart->module_num = proc_list.size();
- flowchart->crcLsb = 0;
- flowchart->crcMsb = 0;
flowchart->compress = 0;
+ flowchart->version = 1;
+ flowchart->crc = 0;
crc = CRC::crc32((const u8*)bin, size);
- flowchart->crcLsb = crc & 0xffff;
- flowchart->crcMsb = crc >> 16;
+ flowchart->crc = crc;
return size;
}
diff --git a/src/scene.h b/src/scene.h
index 0835324..fa4401c 100644
--- a/src/scene.h
+++ b/src/scene.h
@@ -68,17 +68,17 @@
}
//解析inportstr和outportstr,
//字符串转换成逻辑端口号,返回输入输出端口数量.
- s32 str_delim(const s8* str, u8 logic_channel[]) ;
+ s32 str_delim(const s8* str, u16 logic_channel[]) ;
- virtual uvoid* get_module_param_ptr(uvoid *param, s32 fixed) =0;
+ virtual uvoid* get_module_param_ptr(s32 mtype, uvoid *param, s32 fixed) =0;
//根据模块类型更新模块信息.
virtual s32 update_module() =0;
//成功返回0,失败返回-1(内容错误、大小不匹配等).
virtual s32 set_parameters_content(uvoid* param, s32 size) =0;
- virtual u32 get_module_id(u32 mid, s32 mtype ,u32 pid) =0;
+// virtual u32 get_module_id(u32 mid, s32 mtype ,u32 pid) =0;
- s32 convert_to_bin(s8* bin);
+ s32 convert_to_bin(u8* bin);
};
#endif
diff --git a/src/tg/module_def.h b/src/tg/module_def.h
index 8b0fd25..19d1b2e 100644
--- a/src/tg/module_def.h
+++ b/src/tg/module_def.h
@@ -314,6 +314,10 @@
}tag_echo,*ptag_echo;
typedef struct{
+ short bypass;
+ short name[8];
+ short taps;
+ int coeffs[MAX_FIR_TAPS];
}tag_fir, *ptag_fir;
typedef struct{
@@ -325,15 +329,21 @@
typedef struct{
short proc_type;
short pad;
- short proc_ins[sizeof(tag_eq)];
+ char proc_ins[sizeof(tag_eq)];
}tag_module ,*ptag_module;
+typedef struct{
+ short proc_type;
+ short pad;
+ char proc_ins[sizeof(tag_fir)];
+}tag_module_fir, *ptag_module_fir;
+
typedef struct{
- short input_group[MAX_INPUT_NUM];
- short output_group[MAX_OUTPUT_NUM];
+ int input_group[MAX_INPUT_NUM];
+ int output_group[MAX_OUTPUT_NUM];
}tag_group,*ptag_group ;
-
+// ENUM
typedef enum{
INPUT_GAIN = 0x1,
INPUT_MUTE,
diff --git a/src/tg/tg_adapter.cpp b/src/tg/tg_adapter.cpp
index f0c9db4..d227e73 100644
--- a/src/tg/tg_adapter.cpp
+++ b/src/tg/tg_adapter.cpp
@@ -4,27 +4,38 @@
s32 tg_hw_adapter_t::get_physical_channel(s32 input , s32 logic_channel)
{
- //s32 phy_channel[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19};
- if(input) {
- s32 input_num = ana_input_num + dante_input_num ;
- if(logic_channel < ana_input_num) {
- //analog
- return logic_channel;
- }
- else if(logic_channel < input_num) {
- //dante
- return 16+ (logic_channel-ana_input_num);
- }
- else {
- //usb
- return 48 + (logic_channel-input_num);
- }
- }
- else {
- //output
- }
-
- return 0;
+ if(input) {
+ s32 input_num = ana_input_num + dante_input_num ;
+ if(logic_channel < ana_input_num) {
+ //analog
+ return logic_channel + 1;
+ }
+ else if(logic_channel < input_num) {
+ //dante
+ return 19 + (logic_channel - ana_input_num);
+ }
+ else {
+ //usb
+// return 17 + (logic_channel - input_num);
+ return (logic_channel > input_num) ? 17 : 18;
+ }
+ }
+ else { //output
+ s32 output_num = ana_output_num + dante_output_num ;
+ //analog
+ if(logic_channel < ana_output_num) {
+ return logic_channel + 1;
+ }
+ else if(logic_channel < output_num) {
+ //dante
+ return 19 + (logic_channel - ana_output_num);
+ }
+ else {
+ //usb
+// return 17 + (logic_channel - output_num);
+ return (logic_channel > output_num) ? 17 : 18;
+ }
+ }
}
//物理buffer定义顺序是16通道模拟+2通道USB+32通道Dante.
@@ -92,17 +103,18 @@
AddRoute(SourceSignal::SPT0_BD1_O, DestSignal::DAI0_PB12_I);
//USB Slave. SCLK(DAI0_8),LRCLK(DAI0_9), RX(DAI0_7),TX(DAI0_10)
- for(i =4 ;i < 5; i++) {
+ //sport2A<->input; sport2B<->output
+ for(i =4 ;i < 6; i++) {
conf->sports[i].spid = i;
conf->sports[i].clke = utrue;
conf->sports[i].enable = utrue;
conf->sports[i].enable_sec = ufalse;
- conf->sports[i].lfs = ufalse;
- conf->sports[i].mfd = 1;
- conf->sports[i].opmode = 0 ; //tdm
+ conf->sports[i].lfs = ufalse; // The USB left and right channels can be swapped.
+ conf->sports[i].mfd = 0;
+ conf->sports[i].opmode = 1 ; //i2s
conf->sports[i].rx = ufalse;
- conf->sports[i].slots = 8;
- conf->sports[i].vld = 8;
+ conf->sports[i].slots = 2;
+ conf->sports[i].vld = 2;
conf->sports[i].follow_intr_no = intr_sport_no(4);
}
conf->sports[4].interrupt = utrue;
@@ -114,27 +126,100 @@
conf->pcgs[1].fs_div = mclk / conf->mSampleRate ;
conf->pcgs[1].sclk_div = mclk / (conf->mSampleRate * 2 * 32);
AddRoute(SourceSignal::DAI0_PB02_O, DestSignal::PCG_EXTB_I);
+ // route
+ AddRoute(SourceSignal::PCG_FSB_O, DestSignal::SPT2_AFS_I);
+ AddRoute(SourceSignal::PCG_FSB_O, DestSignal::SPT2_BFS_I);
+ AddRoute(SourceSignal::PCG_CLKB_O, DestSignal::SPT2_ACLK_I);
+ AddRoute(SourceSignal::PCG_CLKB_O, DestSignal::SPT2_BCLK_I);
- AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI0_PBEN09_I);//fs
- AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI0_PBEN08_I);//sclk
- AddRoute(SourceSignal::PCG_FSB_O, DestSignal::DAI0_PB09_I);
- AddRoute(SourceSignal::PCG_CLKB_O, DestSignal::DAI0_PB08_I);
+// AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI0_PBEN09_I);//fs
+// AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI0_PBEN08_I);//sclk
+// AddRoute(SourceSignal::PCG_FSB_O, DestSignal::DAI0_PB09_I);
+// AddRoute(SourceSignal::PCG_CLKB_O, DestSignal::DAI0_PB08_I);
- AddRoute(SourceSignal::DAI0_PB08_O, DestSignal::SPT2_ACLK_I);
- AddRoute(SourceSignal::DAI0_PB09_O, DestSignal::SPT2_AFS_I);
- AddRoute(SourceSignal::DAI0_PB08_O, DestSignal::SPT2_BCLK_I);
- AddRoute(SourceSignal::DAI0_PB09_O, DestSignal::SPT2_BFS_I);
+// AddRoute(SourceSignal::DAI0_PB08_O, DestSignal::SPT2_ACLK_I);
+// AddRoute(SourceSignal::DAI0_PB09_O, DestSignal::SPT2_AFS_I);
+// AddRoute(SourceSignal::DAI0_PB08_O, DestSignal::SPT2_BCLK_I);
+// AddRoute(SourceSignal::DAI0_PB09_O, DestSignal::SPT2_BFS_I);
- AddRoute(SourceSignal::DAI0_PB07_O, DestSignal::SPT2_AD0_I);
+// AddRoute(SourceSignal::DAI0_PB07_O, DestSignal::SPT2_AD0_I); // usb output
+// AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI0_PBEN10_I);
+// AddRoute(SourceSignal::SPT2_BD0_O, DestSignal::DAI0_PB10_I); // usb input
+
+ // usb asrc
+ conf->srcs[0].enable = utrue;
+ conf->srcs[0].format = 1;
+ conf->srcs[0].wordLen = 0;
+ conf->srcs[0].ratio = 1; // usb input
+
+ conf->srcs[1].enable = utrue;
+ conf->srcs[1].format = 1;
+ conf->srcs[1].wordLen = 0;
+ conf->srcs[1].ratio = 0; // usb output
+
+ // usb input / asrc input
+ AddRoute(SourceSignal::DAI0_PB09_O, DestSignal::SRC0_FS_IP_I);
+ AddRoute(SourceSignal::DAI0_PB08_O, DestSignal::SRC0_CLK_IP_I);
+ AddRoute(SourceSignal::DAI0_PB07_O, DestSignal::SRC0_DAT_IP_I);
+ // usb input / asrc output
+ AddRoute(SourceSignal::PCG_FSB_O, DestSignal::SRC0_FS_OP_I);
+ AddRoute(SourceSignal::PCG_CLKB_O, DestSignal::SRC0_CLK_OP_I);
+ AddRoute(SourceSignal::SRC0_DAT_OP_O, DestSignal::SPT2_AD0_I);
+ // usb output / asrc input
+ AddRoute(SourceSignal::PCG_FSB_O, DestSignal::SRC1_FS_IP_I);
+ AddRoute(SourceSignal::PCG_CLKB_O, DestSignal::SRC1_CLK_IP_I);
+ AddRoute(SourceSignal::SPT2_BD0_O, DestSignal::SRC1_DAT_IP_I);
+ // usb output / asrc output
+ AddRoute(SourceSignal::DAI0_PB09_O, DestSignal::SRC1_FS_OP_I);
+ AddRoute(SourceSignal::DAI0_PB08_O, DestSignal::SRC1_CLK_OP_I);
AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI0_PBEN10_I);
- AddRoute(SourceSignal::SPT2_BD0_O, DestSignal::DAI0_PB10_I);
+ AddRoute(SourceSignal::SRC1_DAT_OP_O, DestSignal::DAI0_PB10_I);
- //Dante。
+ //Dante Slave
//MCLK(DAI1_2),LRCLK(DAI1_20),SCLK(DAI1_19)
- //RX0(DAI1_12),RX1(DAI1_10),RX2(DAI1_8),RX3(DAI1_6)
- //TX0(DAI1_11),TX1(DAI1_9),TX2(DAI1_7),TX3(DAI1_5)
+ //TX0(DAI1_12),TX1(DAI1_10),TX2(DAI1_8),TX3(DAI1_6)
+ //RX0(DAI1_11),RX1(DAI1_9),RX2(DAI1_7),RX3(DAI1_5)
//sport4a,4b<->RX;sport5a,5b<->TX
for(i = 8 ;i < 12 ;i ++) {
+ conf->sports[i].spid = i;
+ conf->sports[i].clke = utrue;
+ conf->sports[i].enable = utrue;
+ conf->sports[i].enable_sec = ufalse;
+ conf->sports[i].lfs = ufalse;
+ conf->sports[i].mfd = 1;
+ conf->sports[i].opmode = 0 ; //tdm
+ conf->sports[i].rx = ufalse;
+ conf->sports[i].slots = 8;
+ conf->sports[i].vld = 8;
+ conf->sports[i].follow_intr_no = intr_sport_no(8);
+ }
+ conf->sports[8].interrupt = utrue;
+ conf->sports[8].rx = conf->sports[9].rx = utrue;
+
+ AddRoute(SourceSignal::DAI1_PB19_O, DestSignal::SPT4_ACLK_I);
+ AddRoute(SourceSignal::DAI1_PB19_O, DestSignal::SPT4_BCLK_I);
+ AddRoute(SourceSignal::DAI1_PB19_O, DestSignal::SPT5_ACLK_I);
+ AddRoute(SourceSignal::DAI1_PB19_O, DestSignal::SPT5_BCLK_I);
+ AddRoute(SourceSignal::DAI1_PB20_O, DestSignal::SPT4_AFS_I);
+ AddRoute(SourceSignal::DAI1_PB20_O, DestSignal::SPT4_BFS_I);
+ AddRoute(SourceSignal::DAI1_PB20_O, DestSignal::SPT5_AFS_I);
+ AddRoute(SourceSignal::DAI1_PB20_O, DestSignal::SPT5_BFS_I);
+
+ AddRoute(SourceSignal::DAI1_PB11_O, DestSignal::SPT4_AD0_I);
+ AddRoute(SourceSignal::DAI1_PB09_O, DestSignal::SPT4_BD0_I);
+// AddRoute(SourceSignal::DAI1_PB07_O, DestSignal::SPT4_AD0_I);
+// AddRoute(SourceSignal::DAI1_PB05_O, DestSignal::SPT4_BD0_I);
+
+ AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN12_I);
+ AddRoute(SourceSignal::SPT5_AD0_O, DestSignal::DAI1_PB12_I);
+ AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN10_I);
+ AddRoute(SourceSignal::SPT5_BD0_O, DestSignal::DAI1_PB10_I);
+// AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN08_I);
+// AddRoute(SourceSignal::SPT5_AD0_O, DestSignal::DAI1_PB08_I);
+// AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN06_I);
+// AddRoute(SourceSignal::SPT5_BD0_O, DestSignal::DAI1_PB06_I);
+ /* TDM8
+ for(i = 8 ;i < 12 ;i ++) {
conf->sports[i].spid = i;
conf->sports[i].clke = utrue;
conf->sports[i].enable = utrue;
@@ -159,17 +244,17 @@
AddRoute(SourceSignal::DAI1_PB20_O, DestSignal::SPT5_AFS_I);
AddRoute(SourceSignal::DAI1_PB20_O, DestSignal::SPT5_BFS_I);
- AddRoute(SourceSignal::DAI1_PB12_O, DestSignal::SPT4_AD0_I);
- AddRoute(SourceSignal::DAI1_PB10_O, DestSignal::SPT4_AD1_I);
- AddRoute(SourceSignal::DAI1_PB08_O, DestSignal::SPT4_BD0_I);
- AddRoute(SourceSignal::DAI1_PB06_O, DestSignal::SPT4_BD1_I);
+ AddRoute(SourceSignal::DAI1_PB11_O, DestSignal::SPT4_AD0_I);
+ AddRoute(SourceSignal::DAI1_PB09_O, DestSignal::SPT4_AD1_I);
+ AddRoute(SourceSignal::DAI1_PB07_O, DestSignal::SPT4_BD0_I);
+ AddRoute(SourceSignal::DAI1_PB05_O, DestSignal::SPT4_BD1_I);
- AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN11_I);
- AddRoute(SourceSignal::SPT5_AD0_O, DestSignal::DAI1_PB11_I);
- AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN09_I);
- AddRoute(SourceSignal::SPT5_AD1_O, DestSignal::DAI1_PB09_I);
- AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN07_I);
- AddRoute(SourceSignal::SPT5_BD0_O, DestSignal::DAI1_PB07_I);
- AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN05_I);
- AddRoute(SourceSignal::SPT5_BD1_O, DestSignal::DAI1_PB05_I);
+ AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN12_I);
+ AddRoute(SourceSignal::SPT5_AD0_O, DestSignal::DAI1_PB12_I);
+ AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN10_I);
+ AddRoute(SourceSignal::SPT5_AD1_O, DestSignal::DAI1_PB10_I);
+ AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN08_I);
+ AddRoute(SourceSignal::SPT5_BD0_O, DestSignal::DAI1_PB08_I);
+ AddRoute(SourceSignal::LOGIC_HIGH, DestSignal::DAI1_PBEN06_I);
+ AddRoute(SourceSignal::SPT5_BD1_O, DestSignal::DAI1_PB06_I);*/
}
diff --git a/src/tg/tg_adapter.h b/src/tg/tg_adapter.h
index 387323e..d805181 100644
--- a/src/tg/tg_adapter.h
+++ b/src/tg/tg_adapter.h
@@ -18,9 +18,9 @@
}
//
- uvoid config_board(struct DSPConfig * conf);
+ uvoid config_board(struct DSPConfig * conf) override;
- s32 get_physical_channel(s32 input , s32 logic_channel);
+ s32 get_physical_channel(s32 input , s32 logic_channel) override;
};
#endif /* __TIANGONG_H__ */
diff --git a/src/tg/tg_config.h b/src/tg/tg_config.h
index c0d29a7..de4d30a 100644
--- a/src/tg/tg_config.h
+++ b/src/tg/tg_config.h
@@ -10,20 +10,22 @@
#include "config.h"
//项目定制化宏定义.
-#define MAX_INPUT_NUM 32
-#define MAX_OUTPUT_NUM 32
+#define MAX_INPUT_NUM 34 // ana:16, dante:16, usb:2
+#define MAX_OUTPUT_NUM 34
-#define FEEDBACK_FILTERS_NUM 16 //NHS滤波器组数目
+#define FEEDBACK_FILTERS_NUM 16 //NHS滤波器组数目
-#define MAX_MIXER_INPUT 36
-#define MAX_MIXER_OUTPUT 33
+#define MAX_MIXER_INPUT 37
+#define MAX_MIXER_OUTPUT 34
#define MAX_EQ_SECTION 12
-#define AUTOMIXER_CHANNEL_NUM 32
+#define AUTOMIXER_CHANNEL_NUM 34
#define MAX_DELAY_MSEC 1200
#define MAX_DELIM_LEN 32
+#define MAX_FIR_TAPS 1024
+
#ifdef __ADSP21489__
#define RESSIGNBIT(X) (((X)&0x8000)?(-((~(X))&0xffff)-1):(X)) //还原符号位
#elif defined(__ADSP21569__)
diff --git a/src/tg/tg_param_convert.cpp b/src/tg/tg_param_convert.cpp
index 4f3c400..26f9e16 100644
--- a/src/tg/tg_param_convert.cpp
+++ b/src/tg/tg_param_convert.cpp
@@ -57,19 +57,23 @@
u32 tg_param_convert::InputParamCtrl(IModule* m, void* handle, int &plen)
{
- enum GainID {
+ enum Input_ID{
GAIN = 0x1,
MUTE,
SENSI,
PHANTOM,
- PHASE = 9,
- STEP,//-500~+500
- };
+ TYPE,
+ FREQ,
+ LEVEL,
+ NAME,
+ PHASE,
+ STEP,
+ LINK,
+ CHANNEL_LEVEL,
- enum PitchID {
- PITCH_BYPASS = 0x1,//
- PITCH_SEMITONES,//
+ INPUT_MIN,
+ INPUT_MAX,
};
if(handle == NULL) return 1;
@@ -84,9 +88,14 @@
val[1] = RESSIGNBIT(pInput->input[i].gain); m->Ctrl(GAIN, val, 2);
val[1] = RESSIGNBIT(pInput->input[i].mute); m->Ctrl(MUTE, val, 2);
+ val[1] = RESSIGNBIT(pInput->input[i].level); m->Ctrl(LEVEL, val, 2);
val[1] = RESSIGNBIT(pInput->input[i].sensitivity); m->Ctrl(SENSI, val, 2);
val[1] = RESSIGNBIT(pInput->input[i].phant); m->Ctrl(PHANTOM, val, 2);
val[1] = RESSIGNBIT(pInput->input[i].phase); m->Ctrl(PHASE, val, 2);
+
+ val[1] = RESSIGNBIT(pInput->input[i].type); m->Ctrl(TYPE, val, 2);
+ val[1] = RESSIGNBIT(pInput->input[i].freq); m->Ctrl(FREQ, val, 2);
+ val[1] = RESSIGNBIT(pInput->input[i].level); m->Ctrl(LEVEL, val, 2);
}
return 0;
@@ -303,8 +312,9 @@
for(i=0 ;i < pmixer->output_num ;i ++) {
for(j =0 ;j < pmixer->input_num ;j++) {
- val[0] = j; val[1] = i ; val[2] = (pmixer->input_mask[i][j/15]>>(j&15))&0x1; m->Ctrl(MIXER_SWITCH, val, 3);
- val[0] = j; val[1] = i ; val[2] = RESSIGNBIT(pmixer->input_gain[i][j]); m->Ctrl(MIXER_GAIN, val, 3);
+ val[0] = j; val[1] = i; val[2] = (pmixer->input_mask[i][j/15]>>(j&15))&0x1; m->Ctrl(MIXER_SWITCH, val, 3);
+// printf("oich %d %d= %x %x %x\n", i,j, val[0],val[1],val[2]);
+ val[0] = j; val[1] = i; val[2] = RESSIGNBIT(pmixer->input_gain[i][j]); m->Ctrl(MIXER_GAIN, val, 3);
}
}
}
@@ -364,23 +374,6 @@
u32 tg_param_convert::FeedbackParamCtrl(IModule* m, void* handle, int &plen)
{
-// enum NHSID{
-// FB_BYPASS = 0x1,
-// FB_PANIC,
-// FB_THRS,
-// FB_FLT_DEPTH,
-// FB_STEP,
-// FB_FLT_Q,
-// FB_RECYCLETIME,
-//
-// FB_FLT_FREQ,
-// FB_FLT_GAIN,
-// FB_FLT_TYPE,
-//
-// FB_CLEAR, //
-// FB_CLEAR_DYNAMIC,//
-// };
-
enum NHSID{
FB_BYPASS= 0x1,
FB_FLT_FREQ,
@@ -502,12 +495,13 @@
if(handle == NULL) return 1;
- short val[4];
+ short val[4] = {0,0,0,0};
ptag_aec paec = (ptag_aec)handle;
plen = sizeof(tag_aec);
- val[0] = paec->bypass; m->Ctrl(BYPASS, val, 1);
- val[0] = paec->mode; m->Ctrl(NLPLEVEL, val, 1);
+ val[1] = paec->bypass; m->Ctrl(BYPASS, val, 2);
+ val[1] = paec->mode; m->Ctrl(NLPLEVEL, val, 2);
+ val[1] = 2; m->Ctrl(NSMODE, val, 2);
return 0;
}
@@ -848,6 +842,30 @@
return 0;
}
+u32 tg_param_convert::FirParamCtrl(IModule* m, void* handle, int &plen)
+{
+ enum FIRID {
+ FIR_BYPASS = 0x1, ////val[0]: 0-取消bypass, 1- 使能bypass
+ FIR_NAME, //无用
+ FIR_TAPS, //无用
+ FIR_COEFFS, //val: 分包,最大长度1024 float. 无转换直接拷贝float.
+ };
+ if(NULL == handle) return 1;
+
+ ptag_fir pfir = (ptag_fir)handle;
+
+ plen = sizeof(tag_fir);
+ short val[4] = {0};
+ val[0] = pfir->bypass;
+ int taps = pfir->taps;
+ const short *pcoeffs = (const short *)pfir->coeffs;
+
+ m->Ctrl(FIR_BYPASS, val, 1);
+ m->Ctrl(FIR_COEFFS, pcoeffs, taps * 2);
+
+ return 0;
+}
+
u32 tg_param_convert::EmptyParamCtrl(IModule* m, void* handle, int &plen)
{
if(handle == NULL) return 1;
diff --git a/src/tg/tg_param_convert.h b/src/tg/tg_param_convert.h
index a81b01c..6844503 100644
--- a/src/tg/tg_param_convert.h
+++ b/src/tg/tg_param_convert.h
@@ -37,6 +37,7 @@
static u32 GeqParamCtrl(IModule* m, void* handle, int &plen);
static u32 ReverbParamCtrl(IModule* m, void* handle, int &plen);
static u32 EchoParamCtrl(IModule* m, void* handle, int &plen);
+ static u32 FirParamCtrl(IModule* m, void* handle, int &plen);
static u32 EmptyParamCtrl(IModule* m, void* handle, int &plen);
};
diff --git a/src/tg/tg_param_ctrl.cpp b/src/tg/tg_param_ctrl.cpp
index f09b945..443c3b0 100644
--- a/src/tg/tg_param_ctrl.cpp
+++ b/src/tg/tg_param_ctrl.cpp
@@ -44,4 +44,8 @@
mctrl_list.insert(std::pair<u32, ParamEntry>((u32)PROC_AFC, ParamEntry(tg_param_convert::EmptyParamCtrl, tg_param_ctrl::General_Ctrl)));
mctrl_list.insert(std::pair<u32, ParamEntry>((u32)DUMMY_INPUT, ParamEntry(tg_param_convert::EmptyParamCtrl, tg_param_ctrl::General_Ctrl)));
mctrl_list.insert(std::pair<u32, ParamEntry>((u32)DUMMY_OUTPUT, ParamEntry(tg_param_convert::EmptyParamCtrl, tg_param_ctrl::General_Ctrl)));
+ mctrl_list.insert(std::pair<u32, ParamEntry>((u32)PROC_FIR, ParamEntry(tg_param_convert::FirParamCtrl, tg_param_ctrl::Fir_Ctrl)));
}
+
+
+
diff --git a/src/tg/tg_scene.cpp b/src/tg/tg_scene.cpp
index e233423..a6021bb 100644
--- a/src/tg/tg_scene.cpp
+++ b/src/tg/tg_scene.cpp
@@ -1,7 +1,7 @@
/*
* scene.c
*
- * Created on: 2025年7月18日
+ * Created on: 2025骞�鏈�8鏃� * Author: 86189
*/
#include <string.h>
@@ -13,69 +13,93 @@
tgScene::tgScene(hw_adapter_t* adapter):Scene(adapter)
{
- s8 inport_str[8],outport_str[8];
- s8 ana_input_num, ana_output_num,dante_input_num,dante_output_num ;
+ s8 inport_str[16],outport_str[16];
+ s8 ana_input_num, ana_output_num, loc_input_num, loc_output_num, dante_input_num, dante_output_num ;
+ s8 usb_input_num, usb_output_num;
s16 input_num, output_num ;
- s32 n;
+ s32 n, new_idx = 300; //ID of the USB channel starts from 300.
s16 dual_dsp = adapter->get_system_is_dual_dsp();
s16 dsp_index = adapter->get_dsp_index();
- adapter->get_channel_num(&ana_input_num, &ana_output_num, &dante_input_num, &dante_output_num);
- input_num = ana_input_num + dante_input_num;
- output_num = dante_input_num + dante_output_num;
+ adapter->get_channel_num(&loc_input_num, &loc_output_num, &dante_input_num, &dante_output_num, &usb_input_num, &usb_output_num);
+ ana_input_num = loc_input_num - usb_input_num;
+ ana_output_num = loc_output_num - usb_output_num;
- sprintf(inport_str, "0-%d", input_num-1);
+ //鐗╃悊杈撳叆鍏�6+16+2
+ input_num = ana_input_num + dante_input_num + usb_input_num; //2 USB
+ output_num = ana_output_num + dante_output_num + usb_output_num;
+
+ tgScene_param_default(¶meters);
+
+ sprintf(inport_str, "1-%d", input_num);
__MADD(299,PROC_INPUT,inport_str,inport_str,0, 1 ,¶meters.input, 0, ModuleInterfaceType::PHY_INPUT);
+
+ sprintf(inport_str, "1-%d", input_num);
__MADD(298,PROC_METER,inport_str,"",0,1 ,NULL,0, ModuleInterfaceType::SOFT_MODULE); //tag:0-peak,1-rms
//The number of DSPs is 1, but the number of input and output channels is greater than 16.
//It only processes analog input and output.
//However, for the channels that do not need to be processed, the level offset needs to be calculated.
- if(!dual_dsp && input_num >16) {
- n = ana_input_num;
- }
- else {
- n= input_num;
- }
+// if(!dual_dsp && input_num >16) {
+// n = ana_input_num;
+// }
+// else {
+// n= input_num;
+// }
//expander
for(s32 i =0 ;i < input_num ; i++) {
- sprintf(inport_str, "%d|", i);
- __MADD(1+i,PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(inport_str, "%d|", i+1);
+ if(i < input_num - usb_input_num)
+ __MADD(1+i,PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE);
}
//compresser
for(s32 i =0 ;i < input_num ; i++) {
- sprintf(inport_str, "%d|", i);
- __MADD(33+i,PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(inport_str, "%d|", i+1);
+ if(i < input_num - usb_input_num)
+ __MADD(33+i,PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE);
}
//agc
for(s32 i =0 ;i < input_num ; i++) {
- sprintf(inport_str, "%d|", i);
- __MADD(65+i,PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(inport_str, "%d|", i+1);
+ if(i < input_num - usb_input_num)
+ __MADD(65+i,PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE);
}
//eq
for(s32 i =0 ;i < input_num ; i++) {
- sprintf(inport_str, "%d|", i);
- __MADD(97+i,PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(inport_str, "%d|", i+1);
+ if(i < input_num - usb_input_num)
+ __MADD(97+i,PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE);
}
//nhs
for(s32 i =0 ;i < input_num ; i++) {
- sprintf(inport_str, "%d|", i);
- __MADD(129+i,PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(inport_str, "%d|", i+1);
+ if(i < input_num - usb_input_num)
+ __MADD(129+i,PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE);
}
//am
- sprintf(inport_str, "0-%d", input_num-1);
- sprintf(outport_str, "0-%d", input_num);
- __MADD(161,PROC_AUTOMIXER,inport_str, outport_str,0, 0, ¶meters.automixer, 0, ModuleInterfaceType::SOFT_MODULE); //可替换
+ sprintf(inport_str, "1-%d", input_num);
+ sprintf(outport_str, "1-%d", input_num+1);
+ __MADD(161,PROC_AUTOMIXER,inport_str, outport_str, 0, 0, ¶meters.automixer, 0, ModuleInterfaceType::SOFT_MODULE); //驴脡脤忙禄禄
//aec selector
- sprintf(inport_str, "0-%d", input_num+ 1);//+1 add usb
+ sprintf(inport_str, "1-%d", input_num+ 1);
sprintf(outport_str, "%d|%d|", input_num+ 2, input_num+ 3);
__MADD(162,PROC_SELECTOR, inport_str,outport_str, 0, 1, ¶meters.aec_selector, 0, ModuleInterfaceType::SOFT_MODULE); //add usb
@@ -85,7 +109,7 @@
__MADD(163,PROC_AEC,inport_str, outport_str ,0, 1, ¶meters.aec, 256, ModuleInterfaceType::SOFT_MODULE);
//ans selector
- sprintf(inport_str, "0-%d", input_num+ 2);
+ sprintf(inport_str, "1-%d", input_num+ 2);
sprintf(outport_str, "%d|", input_num+ 3);
__MADD(164,PROC_SELECTOR,inport_str,outport_str, 1, 1 ,¶meters.ans_selector, 0, ModuleInterfaceType::SOFT_MODULE);
@@ -95,49 +119,395 @@
__MADD(165,PROC_ANS,inport_str,outport_str, 1, 0 ,¶meters.afc_ns,0, ModuleInterfaceType::SOFT_MODULE);
//mixer
- sprintf(inport_str, "0-%d", input_num+ 3);
- sprintf(outport_str, "0-%d", output_num);
- __MADD(166,PROC_MIXER,"0-35","0-32",1, 1 ,¶meters.mixer, 0, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(inport_str, "1-%d", input_num+ 3);
+ sprintf(outport_str, "%d-%d",input_num+4, input_num+output_num+4);
+ __MADD(166,PROC_MIXER,inport_str,outport_str,1, 1 ,¶meters.mixer, 0, ModuleInterfaceType::SOFT_MODULE); // .begin()+48
//crossover
for(s32 i =0 ;i < output_num ; i++) {
- sprintf(outport_str, "%d|", i);
- __MADD(167,PROC_CROSSOVER,outport_str, outport_str,1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(inport_str, "%d|", i+input_num+4);
+ sprintf(outport_str, "%d|", i+1);
+ if(i < output_num - usb_output_num)
+ __MADD(167+i,PROC_CROSSOVER,inport_str,outport_str,1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_CROSSOVER,inport_str,outport_str,1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE);
}
//eq
for(s32 i =0 ;i < output_num ; i++) {
- sprintf(outport_str, "%d|", i);
- __MADD(199,PROC_EQ,outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(outport_str, "%d|", i+1);
+ if(i < output_num - usb_output_num)
+ __MADD(199+i,PROC_EQ,outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_EQ,outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE);
}
//delay
for(s32 i =0 ;i < output_num ; i++) {
- sprintf(outport_str, "%d|", i);
- __MADD(231,PROC_DELAY,outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(outport_str, "%d|", i+1);
+ if(i < output_num - usb_output_num)
+ __MADD(231+i,PROC_DELAY,outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_DELAY,outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE);
}
//limit
for(s32 i =0 ;i < output_num ; i++) {
- sprintf(outport_str, "%d|", i);
- __MADD(263,PROC_LIMIT,outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE);
+ sprintf(outport_str, "%d|", i+1);
+ if(i < output_num - usb_output_num)
+ __MADD(263+i,PROC_LIMIT,outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE);
+ else
+ __MADD(new_idx++,PROC_LIMIT,outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE);
}
//output
- sprintf(outport_str, "0-%d", output_num-1);
+ sprintf(outport_str, "1-%d", output_num);
__MADD(295,PROC_OUTPUT,outport_str,outport_str,1, 1, ¶meters.output,0, ModuleInterfaceType::SOFT_MODULE);
//sysctrl
__MADD(296,PROC_SYSCTL,outport_str,outport_str,1, 1, ¶meters.sysctl,0, ModuleInterfaceType::PHY_OUTPUT);
//meter
__MADD(297,PROC_METER,outport_str,"",1, 1, NULL, 0, ModuleInterfaceType::SOFT_MODULE);
+
+
};
+
+
+void tgScene::module_def(s32 proc_type, void* param_ptr)
+{
+ int j;
+ int allbypass = 1;
+ switch(proc_type) {
+
+ case PROC_INPUT:
+ ptag_input pInput = (ptag_input)param_ptr;
+ pInput->input_num = MAX_INPUT_NUM;
+ for(j=0; j<pInput->input_num; j++){
+ pInput->input[j].freq = 1000;
+ pInput->input[j].level = -4800;
+ pInput->input[j].phant = 0;
+ pInput->input[j].sensitivity = 0;
+ pInput->input[j].channelID = j;
+ pInput->input[j].gain =0;
+ pInput->input[j].mute = 0;
+ pInput->input[j].type=0;
+ pInput->input[j].phase =0 ;
+ pInput->input[j].mingain = -8000;
+ pInput->input[j].maxgain = 1200;
+ }
+ break;
+
+ case PROC_METER:
+ ptag_Meter pMeter = (ptag_Meter)param_ptr;
+ pMeter->input_num = 8;
+ break;
+
+ case PROC_SHELF:
+ ptag_shelf pshelf = (ptag_shelf)param_ptr;
+ pshelf->highshelf.bypass = allbypass;
+ pshelf->highshelf.freq = 500;
+ pshelf->highshelf.gain = -4500;
+ pshelf->highshelf.q = 71;
+ pshelf->lowshelf.bypass = 1;
+ pshelf->lowshelf.freq = 500;
+ pshelf->lowshelf.gain =-4500;
+ pshelf->lowshelf.q = 71;
+ break;
+
+ case PROC_GEQ:
+ int j;
+ ptag_geq pGEQ = (ptag_geq)param_ptr;
+ pGEQ->bypass = allbypass;
+ pGEQ->q = 2;
+ pGEQ->nsections = 31;
+ for(j=0;j<31;j++){
+ pGEQ->eq_attr[j].gain = 0;
+ }
+ break;
+ case PROC_EQ:
+ ptag_eq pEQ = (ptag_eq)param_ptr;
+ u16 freq[]={40,80,200,500,1000,2000,4000,8000,10000,12500,16000,20000};
+ pEQ->bypass = allbypass;
+ pEQ->nsection = MAX_EQ_SECTION;
+ for(j=0;j<pEQ->nsection;j++){
+ pEQ->eq_attr[j].bypass = allbypass;
+ pEQ->eq_attr[j].freq = freq[j];
+ pEQ->eq_attr[j].gain = 0;
+ pEQ->eq_attr[j].q = 250;
+ //pEQ->eq_attr[j].type =
+ }
+ break;
+
+ case PROC_EXPANDER:
+ ptag_expander pExpander = (ptag_expander)param_ptr;
+ pExpander->bypass = allbypass;
+ pExpander->threshold = -6000;
+ pExpander->ratio = 100;
+ pExpander->attack = 1;
+ pExpander->release = 1;
+ break;
+
+ case PROC_COMPRESS:
+ ptag_compress pcompress = (ptag_compress)param_ptr;
+ pcompress->bypass = allbypass;
+ pcompress->threshold = -4800;
+ pcompress->ratio = 100;
+ pcompress->attack = 1;
+ pcompress->release = 1;
+ pcompress->gain = 0;
+ pcompress->soft = 0;
+ break;
+
+ case PROC_LIMIT:
+ ptag_compress limiter = (ptag_compress)param_ptr;
+ limiter->bypass = allbypass;
+ limiter->threshold = 0;
+ limiter->ratio = 10000;
+ limiter->attack = 1;
+ limiter->release = 1;
+ limiter->gain = 0;
+ limiter->soft = 0;
+ break;
+
+ case PROC_MIXER:
+ int m;
+ ptag_mixer pMixer = (ptag_mixer)param_ptr;
+ pMixer->input_num = MAX_MIXER_INPUT;
+ pMixer->output_num = MAX_MIXER_OUTPUT;
+ memset(pMixer->input_mask,0,sizeof(pMixer->input_mask));
+ for (m=0;m<pMixer->output_num ;m ++){
+ for(j=0;j<pMixer->input_num;j++){
+ pMixer->input_gain[m][j]=0;
+ pMixer->delay[m][j] =0;
+ }
+ pMixer->input_mask[m][m/16]=1<<(m&15);
+ }
+ break;
+
+ case PROC_DELAY:
+ ptag_delay pDelay = (ptag_delay)param_ptr;
+ pDelay->bypass = allbypass;
+ pDelay->ms = 1;
+ break;
+
+ case PROC_CROSSOVER:
+ ptag_crossover pCross = (ptag_crossover)param_ptr;
+ pCross->highpass.bypass = allbypass;
+ pCross->highpass.freq = 500;//454;
+ pCross->highpass.taps = 18;//48;
+ pCross->highpass.type = 0;
+ pCross->highpass.gain =0 ;
+ pCross->lowpass.bypass = allbypass;
+ pCross->lowpass.freq = 500;
+ pCross->lowpass.taps = 18;
+ pCross->lowpass.type = 0;
+ pCross->lowpass.gain =0;
+ break;
+
+ case PROC_OUTPUT:
+ ptag_output pOutput= (ptag_output)param_ptr;
+ pOutput->output_num = MAX_OUTPUT_NUM;
+ for(j=0;j<pOutput->output_num;j++){
+ pOutput->output[j].gain = 0;
+ pOutput->output[j].mute = 0;
+ pOutput->output[j].channelID = j;
+ pOutput->output[j].phase = 0;
+ pOutput->output[j].mingain = -8000;
+ pOutput->output[j].maxgain = 1200;
+ }
+ break;
+
+ case PROC_GAIN:
+ ptag_gain pgain = (ptag_gain)param_ptr;
+ pgain->gain = 0;
+ pgain->mute = 0;
+ break;
+
+ case PROC_AUTOMIXER:
+ ptag_gainsharing_mixer pautomixer = (ptag_gainsharing_mixer)param_ptr;
+ pautomixer->bypass = allbypass;
+ pautomixer->master_mute =0;
+ pautomixer->master_gain =0;
+ pautomixer->response = 5;
+ pautomixer->slope = 200;
+ for(j=0;j<AUTOMIXER_CHANNEL_NUM;j++){
+ pautomixer->channels[j].automatic = 0;
+ pautomixer->channels[j].mute = 0;
+ pautomixer->channels[j].gain = 0;
+ pautomixer->channels[j].priority = 5;
+ }
+ break;
+
+ case PROC_FEEDBACK:
+ ptag_feedback pfb = (ptag_feedback)param_ptr;
+ pfb->bypass = allbypass;
+ pfb->panic_threshold = 0;
+ pfb->flt_depth = 1800;
+ break;
+
+ case PROC_SYSCTL:
+ ptag_sysctl psysctl = (ptag_sysctl)param_ptr;
+ psysctl->gain = 0;
+ psysctl->mute = 0;
+ break;
+
+ case PROC_AEC:
+ ptag_aec paec = (ptag_aec)param_ptr;
+ paec->bypass = allbypass;
+ paec->mode = 0;
+ break;
+
+ case PROC_ANS:
+ ptag_ans pans = (ptag_ans)param_ptr;
+ pans->bypass = allbypass;
+ pans->mode = 0;
+ break;
+
+ case PROC_SELECTOR:
+ ptag_selector pselector = (ptag_selector)param_ptr;
+ pselector->input_num = MAX_MIXER_INPUT;
+ pselector->output_num = MAX_MIXER_OUTPUT;
+ memset(pselector->input_mask,0,sizeof(pselector->input_mask));
+ break;
+
+ case PROC_AGC:
+ ptag_agc pAGC = (ptag_agc)param_ptr;
+ pAGC->bypass = allbypass;
+ pAGC->attacktime = 1;
+ pAGC->releasetime = 500;
+ pAGC->ratio = 100;
+ pAGC->tar_threshold = 0;
+ pAGC->threshold =-4800;
+ break;
+
+ case PROC_GATING_AUTOMIXER:
+ ptag_gating_mixer pgautomixer = (ptag_gating_mixer)param_ptr;
+ pgautomixer->bypass = allbypass;
+ pgautomixer->master_mute =0;
+ pgautomixer->master_gain =0;
+ pgautomixer->holdtime = 500;
+ pgautomixer->offgain = -4000;
+ pgautomixer->sensitivity = 600;
+ pgautomixer->nom_atten = 300;
+ pgautomixer->nom_num = 4;
+ for(j=0;j<AUTOMIXER_CHANNEL_NUM;j++){
+ pgautomixer->channels[j].automatic = 0;
+ pgautomixer->channels[j].mute = 0;
+ pgautomixer->channels[j].gain = 0;
+ pgautomixer->channels[j].priority = 5;
+ }
+ break;
+
+ case PROC_CONTINUNOUS_SPL:
+ ptag_spl pspl = (ptag_spl)param_ptr;
+ pspl->maxgain = 2000;
+ pspl->mingain = -2000;
+ pspl->sense_ratio = 75;
+ pspl->speed = 5;
+ pspl->trim =0;
+ pspl->bypass = allbypass;
+ memset((void*)pspl->mask,0,sizeof(pspl->mask));
+ break;
+
+ case PROC_GATING:
+ ptag_gate pgate = (ptag_gate)param_ptr;
+ pgate->bypass = allbypass;
+ pgate->threshold = -3000;
+ pgate->depth = -6000;
+ pgate->attacktime = 2;
+ pgate->holdtime = 5;
+ pgate->releasetime = 1000;
+ break;
+
+ case PROC_DUCKER:
+ ptag_ducker pducker = (ptag_ducker)param_ptr;
+ pducker->bypass = allbypass;
+ pducker->threshold = -4500;
+ pducker->depth = -2000;
+ pducker->attacktime = 20;
+ pducker->holdtime = 1000;
+ pducker->releasetime = 1000;
+ memset((void*)pducker->mask,0,sizeof(pducker->mask));
+ break;
+
+ case PROC_REVERB:
+ break;
+
+ case PROC_ECHO:
+ break;
+
+ case PROC_FIR:
+ ptag_fir pfir = (ptag_fir)param_ptr;
+ pfir->bypass = allbypass;
+ pfir->taps = 1024;
+ memset((void*)pfir->coeffs, 0, sizeof(pfir->coeffs));
+ pfir->coeffs[0] = 1;
+ break;
+
+ default:
+ break;
+
+ }
+}
+
+
+void tgScene::tgScene_param_default(ptag_parameters p)
+{
+ int i,j,module_cnt=0;
+
+ module_def(PROC_INPUT, &p->input);
+
+ for (i=0; i<MAX_INPUT_NUM; i++) {
+ module_def(PROC_EXPANDER, &p->in1[i]);
+ module_def(PROC_COMPRESS, &p->in2[i]);
+ module_def(PROC_AGC, &p->in3[i]);
+ module_def(PROC_EQ, &p->in4[i]);
+ module_def(PROC_FEEDBACK, &p->in5[i]);
+ }
+
+ module_def(PROC_AUTOMIXER, &p->automixer);
+ module_def(PROC_SELECTOR, &p->aec_selector);
+ module_def(PROC_AEC, &p->aec);
+ module_def(PROC_SELECTOR, &p->ans_selector);
+ module_def(PROC_ANS, &p->ans_selector);
+ module_def(PROC_MIXER, &p->mixer);
+
+ for (i=0; i<MAX_OUTPUT_NUM; i++) {
+ module_def(PROC_CROSSOVER, &p->out1[i]);
+ module_def(PROC_EQ, &p->out2[i]);
+ module_def(PROC_DELAY, &p->out3[i]);
+ module_def(PROC_LIMIT, &p->out4[i]);
+ }
+
+ module_def(PROC_OUTPUT, &p->output);
+ module_def(PROC_SYSCTL, &p->sysctl);
+}
s32 tgScene::set_parameters_content(uvoid* param, s32 size)
{
tag_parameters* pp = (tag_parameters*)param;
- if(pp->magic != 0xb34c && size != sizeof(tag_parameters)) {
- //basic check.
+ int L[24] = {0};
+ if(pp->magic != 0xbcba || size != sizeof(tag_parameters)) {
+ printf("preset param error!\n");
+ /*printf("tag_head:%d,%d,%d,%d,%d\n", L[0]=sizeof(parameters.magic), L[1]=sizeof(parameters.nmds)+L[0], L[2]=sizeof(parameters.pad1)+L[1], L[3]=sizeof(parameters.pad2)+L[2], L[4]=sizeof(parameters.crc)+L[3]);
+ printf("tag_input:%d, %d\n", sizeof(tag_input), L[5]=sizeof(tag_input)+L[4]);
+ printf("tag_module_in:%d, %d\n", sizeof(tag_module), L[6]=sizeof(tag_module) * MAX_INPUT_NUM * 5 + L[5]);
+
+ printf("tag_automixer:%d, %d\n", sizeof(tag_automixer), L[7]=sizeof(tag_automixer)+L[6]);
+ printf("tag_select1:%d, %d\n", sizeof(tag_selector), L[8]=sizeof(tag_selector)+L[7]);
+ printf("tag_aec:%d, %d\n", sizeof(tag_aec), L[9]=sizeof(tag_aec)+L[8]);
+ printf("tag_selector:%d, %d\n", sizeof(tag_selector), L[10]=sizeof(tag_selector) + L[9]);
+ printf("tag_3a:%d, %d, %d\n", sizeof(tag_3a), L[11]=sizeof(tag_3a)+L[10]);
+ printf("tag_mixer:%d, %d\n", sizeof(tag_mixer), L[12]=sizeof(tag_mixer)+L[11]);
+
+ printf("tag_module_o1:%d, %d\n", sizeof(tag_module), L[13]=sizeof(tag_module) * MAX_INPUT_NUM + L[12]);
+ printf("tag_module_fir:%d\n", sizeof(tag_module_fir), L[14]=sizeof(tag_module_fir) * MAX_OUTPUT_NUM + L[13]);
+ printf("tag_module_out:%d\n", sizeof(tag_module), L[15]=sizeof(tag_module) * MAX_OUTPUT_NUM * 2 + L[14]);
+ printf("tag_output:%d, %d\n", sizeof(tag_output), L[16]=sizeof(tag_output)+L[15]);
+ printf("tag_sysctl:%d, %d\n", sizeof(tag_sysctl), L[17]=sizeof(tag_sysctl)+L[16]);
+ printf("tag_group:%d, %d\n", sizeof(tag_group), L[18]=sizeof(tag_group)+L[17]);*/
+
+ printf("Len parameters:%d, Len recv:%d\n", L[19]=sizeof(tag_parameters), size);
return -1;
}
memcpy(¶meters, param, sizeof(tag_parameters));
@@ -145,17 +515,17 @@
return 0;
}
-s32 tgScene::update_dynmodule_tag(s32 proc_type,struct proc_field* proc)
+s32 tgScene::update_dynmodule_tag(s32 proc_type, struct proc_field* proc)
{
switch(proc_type) {
- case ModuleType::PROC_EQ:{
+ case ModuleType::PROC_GEQ:{
ptag_module pmodule = (ptag_module)proc->parameters;
ptag_geq geq = (ptag_geq)pmodule->proc_ins;
proc->tag = geq->nsections;
}
break;
- case ModuleType::PROC_GEQ:{
+ case ModuleType::PROC_EQ:{
ptag_module pmodule = (ptag_module)proc->parameters;
ptag_eq eq = (ptag_eq)pmodule->proc_ins;
@@ -174,7 +544,7 @@
proc->tag =1200;
break;
case ModuleType::PROC_CROSSOVER:
- proc->tag =2;
+ proc->tag =1;
break;
case ModuleType::PROC_FEEDBACK:{
ptag_module pmodule = (ptag_module)proc->parameters;
@@ -205,15 +575,14 @@
s32 tgScene::update_module()
{
- u8 port_number[16];
- s8 ana_input_num, ana_output_num,dante_input_num,dante_output_num ;
+ s8 ana_input_num, ana_output_num,dante_input_num,dante_output_num, usb_input_num, usb_output_num ;
s16 input_num, output_num ;
s16 dual_dsp = hw_adapter->get_system_is_dual_dsp();
s16 dsp_index = hw_adapter->get_dsp_index();
- hw_adapter->get_channel_num(&ana_input_num, &ana_output_num, &dante_input_num, &dante_output_num);
+ hw_adapter->get_channel_num(&ana_input_num, &ana_output_num, &dante_input_num, &dante_output_num, &usb_input_num, &usb_output_num);
input_num = ana_input_num + dante_input_num;
- output_num = dante_input_num + dante_output_num;
+ output_num = ana_output_num + dante_output_num;
for(auto& iter: proc_list){
//update dynamic module info.
@@ -222,67 +591,40 @@
if(pmodule->proc_type >= ModuleType::PROC_COUNT || pmodule->proc_type < ModuleType::PROC_NONE) {
pmodule->proc_type = ModuleType::PROC_NONE;
}
- update_dynmodule_tag(pmodule->proc_type, &iter);
-// if(iter.dsp_index == 0) {
-// s32 n = input_num;
-// s32 ninports = str_delim((const s8*)iter.inportstr, port_number);
-//
-// //Consider PCM model&& PCM channel don't process.
-// if(dual_dsp == 0 && input_num >16){
-// n = ana_input_num;
-// }
-//
-// if(ninports == 1 && port_number[0] >= n){
-// iter.proc_type = ModuleType::PROC_NONE;//便于解析场景过滤
-// //even though module not to process, but the pc has level offset.
-// if(port_number[0] >= input_num) {
-//
-// }
-// }
-// }
-// else {
-// s32 n = output_num;
-// s32 ninports = str_delim(iter.inportstr, port_number);
-//
-// if(dual_dsp == 0 && output_num >16){
-// n = ana_output_num;
-// }
-//
-// if(ninports==1 && port_number[0] >= n){
-// iter.proc_type = ModuleType::PROC_NONE; //便于解析场景过滤
-// //even though module not to process, but the pc has level offset.
-// if(port_number[0] >= output_num) {
-//
-// }
-// }
-// }
+ update_dynmodule_tag(pmodule->proc_type, &iter);
}
}
return 0;
}
-uvoid* tgScene::get_module_param_ptr(uvoid *param, s32 fixed)
+uvoid* tgScene::get_module_param_ptr(s32 mType, uvoid *param, s32 fixed)
{
uvoid *ptr = param;
if(fixed == 0){
- ptag_module pmod = (ptag_module)param;
- ptr = (void*)pmod->proc_ins;
+ if (PROC_FIR == mType) {
+ ptag_module_fir pmod = (ptag_module_fir)param;
+ ptr = (void*)pmod->proc_ins;
+ }
+ else {
+ ptag_module pmod = (ptag_module)param;
+ ptr = (void*)pmod->proc_ins;
+ }
}
return ptr;
}
-u32 tgScene::get_module_id(u32 mid, s32 mtype , u32 pid)
-{
- if(mtype == PROC_INPUT && (pid == INPUT_TYPE || pid == INPUT_FREQ || pid == INPUT_LEVEL)){
- mid = 300;
- }
- else if(mtype == PROC_DUCKER && pid == DUCKER_MIX){
- mid = mid + 320;
- }
-
- return mid;
-}
+//u32 tgScene::get_module_id(u32 mid, s32 mtype , u32 pid)
+//{
+// if(mtype == PROC_INPUT && (pid == INPUT_TYPE || pid == INPUT_FREQ || pid == INPUT_LEVEL)){
+// mid = 300;
+// }
+// else if(mtype == PROC_DUCKER && pid == DUCKER_MIX){
+// mid = mid + 320;
+// }
+//
+// return mid;
+//}
diff --git a/src/tg/tg_scene.h b/src/tg/tg_scene.h
index cc34a79..de25cbe 100644
--- a/src/tg/tg_scene.h
+++ b/src/tg/tg_scene.h
@@ -10,42 +10,43 @@
#include <vector>
#include "../scene.h"
+#include "../protocol.h"
#include "module_def.h"
+#pragma pack (1)
typedef struct {
unsigned short magic;
unsigned short nmds;
unsigned short pad1;
unsigned short pad2;
-
unsigned short crc[2];
+ tag_input input; //1362
- tag_input input;//514
-
- tag_module in1[MAX_INPUT_NUM];
+ tag_module in1[MAX_INPUT_NUM]; //4352
tag_module in2[MAX_INPUT_NUM];
tag_module in3[MAX_INPUT_NUM];
tag_module in4[MAX_INPUT_NUM];
tag_module in5[MAX_INPUT_NUM];
- tag_automixer automixer;//138
- tag_selector aec_selector; //68
- tag_aec aec; //4
- tag_selector ans_selector; //68
- tag_3a afc_ns;//4
- tag_mixer mixer; //728 -4
+ tag_automixer automixer; //366
+ tag_selector aec_selector; //208
+ tag_aec aec; //4
+ tag_selector ans_selector; //208
+ tag_3a afc_ns; //36
+ tag_mixer mixer; //5242
- tag_module out1[MAX_OUTPUT_NUM];
- tag_module out2[MAX_OUTPUT_NUM];
- tag_module out3[MAX_OUTPUT_NUM];
- tag_module out4[MAX_OUTPUT_NUM];
- tag_output output;
- tag_sysctl sysctl;
- tag_group group;
+ tag_module out1[MAX_OUTPUT_NUM]; //4352
+// tag_module out2[MAX_OUTPUT_NUM];
+ tag_module_fir out2[MAX_OUTPUT_NUM]; //140080
+ tag_module out3[MAX_OUTPUT_NUM];
+ tag_module out4[MAX_OUTPUT_NUM];
+ tag_output output; //1158
+ tag_sysctl sysctl; //6
+ tag_group group; //272
} tag_parameters, *ptag_parameters;
-
+#pragma pack ()
class tgScene: public Scene
{
@@ -56,15 +57,22 @@
s32 update_dynmodule_tag(s32 proc_type,struct proc_field* proc);
public:
tgScene(hw_adapter_t* adapter);
+ void module_def(s32 proc_type, void* param_ptr);
+ void tgScene_param_default(ptag_parameters p);
//根据模块类型更新模块信息.
virtual s32 update_module() override;
virtual s32 set_parameters_content(uvoid* param, s32 size) override;
- virtual uvoid* get_module_param_ptr(uvoid *param, s32 fixed) override;
+ virtual uvoid* get_module_param_ptr(s32 mType, uvoid *param, s32 fixed) override;
- virtual u32 get_module_id(u32 mid, s32 mtype ,u32 pid) override;
+// virtual u32 get_module_id(u32 mid, s32 mtype ,u32 pid) override;
};
+
+//void param_init(ptag_device_config pDevCfg);
+//void preset_init(tag_parameters *p);
+
+
#endif /* TG_SCENE_H_ */
diff --git a/src/tg/tg_user_ctrl.cpp b/src/tg/tg_user_ctrl.cpp
index 21c176a..96497a4 100644
--- a/src/tg/tg_user_ctrl.cpp
+++ b/src/tg/tg_user_ctrl.cpp
@@ -4,12 +4,13 @@
* Created on: 2025年7月24日
* Author: 86189
*/
+#include <stdio.h>
#include "IModule.h"
#include "module_def.h"
#include "tg_user_ctrl.h"
-u32 tg_param_ctrl::Signalgen_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Signalgen_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum SGItemType{
SG_MUTE = 0x1,
@@ -49,41 +50,37 @@
return 0;
}
-u32 tg_param_ctrl::Input_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Input_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
- enum GainID {
+ enum Input_ID{
GAIN = 0x1,
MUTE,
SENSI,
PHANTOM,
- PHASE = 9,
- STEP,//-500~+500
+ TYPE,
+ FREQ,
+ LEVEL,
+ NAME,
+ PHASE,
+ STEP,
+ LINK,
+ CHANNEL_LEVEL,
+
+ INPUT_MIN,
+ INPUT_MAX,
};
-
-
- enum PitchID {
- PITCH_BYPASS = 0x1,//
- PITCH_SEMITONES,//
- };
-
short val[4];
- int channel = val_c[0]&(MAX_INPUT_NUM-1);
+ int channel = val_c[0];//&(MAX_INPUT_NUM-1);
- if(pID == INPUT_STEP) {
- val[0] = channel; val[1] = RESSIGNBIT(val_c[1]);
- m->Ctrl(STEP, val, 2);
- }
- else {
- val[0] = channel; val[1] = RESSIGNBIT(val_c[1]);
- m->Ctrl(pID, val, 2);
- }
+ val[0] = channel; val[1] = RESSIGNBIT(val_c[1]);
+ m->Ctrl(pID, val, 2);
return 0;
}
-u32 tg_param_ctrl::Gain_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Gain_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum GainID {
GAIN = 0x1,
@@ -96,7 +93,7 @@
};
short val[4];
- int channel = val_c[0]&(MAX_INPUT_NUM-1);
+ int channel = val_c[0];//&(MAX_INPUT_NUM-1);
if(pID == 0x20) {
val[0] = channel; val[1] = RESSIGNBIT(val_c[1]);
@@ -106,7 +103,7 @@
return 0;
}
-u32 tg_param_ctrl::Output_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Output_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum GainID {
GAIN = 0x1,
@@ -119,7 +116,7 @@
};
short val[4];
- int channel = val_c[0]&(MAX_OUTPUT_NUM-1);
+ int channel = val_c[0];//&(MAX_OUTPUT_NUM-1);
short cmd[16] = {GAIN, MUTE, 0, PHASE, SENSI, STEP, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 };
val[0] = channel;
@@ -130,7 +127,7 @@
return 0;
}
-u32 tg_param_ctrl::Mixer_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Mixer_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
short val[4];
@@ -152,7 +149,7 @@
return 0;
}
-u32 tg_param_ctrl::Crossover_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Crossover_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum CFilterID {
_BYPASS = 0x1,
@@ -179,7 +176,7 @@
return 0;
}
-u32 tg_param_ctrl::Feedback_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Feedback_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
// enum NHSID{
// FB_BYPASS = 0x1,
@@ -223,7 +220,7 @@
return 0;
}
-u32 tg_param_ctrl::Automixer_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Automixer_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum GainSharingAMID {
AM_BYPASS =0x1,
@@ -247,7 +244,7 @@
return 0;
}
-u32 tg_param_ctrl::Aec_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Aec_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum AECID{
BYPASS = 0X1,
@@ -265,18 +262,16 @@
AGC_GAIN,
};
+ short val[4] = {0,0,0,0};
+ short cmd[3] = {0, BYPASS, NLPLEVEL};
- short val[4];
- short cmd[12] = {0, BYPASS, NLPLEVEL, 0, 0,0};
-
- val[0] = RESSIGNBIT(val_c[0]);
- val[1] = RESSIGNBIT(val_c[1]);
- m->Ctrl(cmd[pID], val, 1);
+ val[1] = RESSIGNBIT(val_c[0]);
+ m->Ctrl(cmd[pID], val, 2);
return 0;
}
-u32 tg_param_ctrl::Sysctl_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Sysctl_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum SYSCTRLID{
SYSCTL_MUTE = 0x1, //val[0]:0-unmute,1-mute
@@ -292,7 +287,7 @@
return 0;
}
-u32 tg_param_ctrl::Geq_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Geq_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum EQID{
EQ_BYPASS_ALL = 0x1,
@@ -314,7 +309,7 @@
return 0;
}
-u32 tg_param_ctrl::Reverb_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Reverb_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
short val[4];
@@ -326,7 +321,7 @@
return 0;
}
-u32 tg_param_ctrl::Echo_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::Echo_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
enum EchoID{
ECHO_BYPASS = 1,
@@ -346,7 +341,7 @@
return 0;
}
-u32 tg_param_ctrl::General_Ctrl(IModule* m, u32 pID, s16* val_c)
+u32 tg_param_ctrl::General_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
{
short val[4];
@@ -354,8 +349,38 @@
val[1] = RESSIGNBIT(val_c[1]);
m->Ctrl(pID, val, 2);
+// printf("pID:%d v[0]:%d v[1]:%d\n", pID, val[0], val[1]);
return 0;
}
+u32 tg_param_ctrl::Fir_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num)
+{
+ enum FIRID {
+ FIR_BYPASS = 0x1, ////val[0]: 0-取消bypass, 1- 使能bypass
+ FIR_NAME, //无用
+ FIR_TAPS, //无用
+ FIR_COEFFS, //val: 分包,最大长度1024 float. 无转换直接拷贝float.
+ };
+ s16 val[4];
+ val[0] = RESSIGNBIT(val_c[0]);
+
+ if(FIR_BYPASS == pID){
+ m->Ctrl(pID, val, 1); // val[0] is bypass or nobypass
+ }
+ else if (FIR_COEFFS == pID){
+ m->Ctrl(pID, val_c, num);
+ }
+
+ return 0;
+}
+
+
+
+
+
+
+
+
+
diff --git a/src/tg/tg_user_ctrl.h b/src/tg/tg_user_ctrl.h
index ec3af28..76ada01 100644
--- a/src/tg/tg_user_ctrl.h
+++ b/src/tg/tg_user_ctrl.h
@@ -11,20 +11,21 @@
class tg_param_ctrl {
public:
- static u32 Signalgen_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Input_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Gain_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Output_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Mixer_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Crossover_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Feedback_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Automixer_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Aec_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Sysctl_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Geq_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Reverb_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 Echo_Ctrl(IModule* m, u32 pID, s16* val_c);
- static u32 General_Ctrl(IModule* m, u32 pID, s16* val_c);
+ static u32 Signalgen_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Input_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Gain_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Output_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Mixer_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Crossover_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Feedback_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Automixer_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Aec_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Sysctl_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Geq_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Reverb_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Echo_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 General_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
+ static u32 Fir_Ctrl(IModule* m, u32 pID, s16* val_c, u32 num);
};
diff --git a/src/tob.cpp b/src/tob.cpp
index 22f4e44..8d34e61 100644
--- a/src/tob.cpp
+++ b/src/tob.cpp
@@ -6,6 +6,7 @@
*/
#include <stdlib.h>
#include <stdio.h>
+#include <heapnew>
#include "tob.h"
#include "crc.h"
#include "config.h"
@@ -13,7 +14,8 @@
#include "IModule.h"
#include "f2f.h"
#include "../drv/memory.h"
-#include "param_ctrl.h"
+
+
//#define DEBUG
#ifdef DEBUG
@@ -22,31 +24,32 @@
#define dbg_printf
#endif
-static ToB* tob = NULL;
+//static ToB* tob = NULL;
-ToB* ToB::GetInstance()
-{
- return tob;
-}
+//ToB* ToB::GetInstance()
+//{
+// return tob;
+//}
ToB::ToB(ubool dualDsp, u32 dspIndex )
- : dual_dsp(dualDsp), dsp_index(dspIndex),mList(32)
+ : dual_dsp(dualDsp), dsp_index(dspIndex)
{
- if(tob != NULL) {
- delete tob;
- }
- tob = this;
- frames = NULL;
+// if(tob != NULL) {
+// delete tob;
+// }
+// tob = this;
+ frames = nullptr;
processed = ufalse;
mModuleNum =0;
- mLevelPacketNum =0;
mModuleIndex.resize(0);
+ paramset = new(SRAM_DDR) tg_param_ctrl_t();
}
ToB::~ToB()
{
toClear();
- tob = NULL;
+// tob = NULL;
+ delete paramset;
}
uvoid ToB::SetMute(ubool mute)
@@ -56,16 +59,23 @@
ErrStatus ToB::toClear()
{
processed = ufalse;
+ int i = 0;
- for (std::vector<IModule*>::iterator iter = mList.begin();
- iter != mList.end() ;iter++) {
- delete *iter;
+// for (std::vector<IModule*>::iterator iter = mList.begin(); iter != mList.end(); iter++, ++i) {
+// delete *iter;
+// *iter = nullptr;
+// }
+ for (auto iter : mList) {
+ delete iter;
+ iter = nullptr;
}
+
mList.clear();
mModuleIndex.clear();
if(frames != NULL) {
delete frames;
+ frames = nullptr;
}
mModuleNum = 0;
@@ -93,7 +103,6 @@
u32 size = sizeof(FlowChartHead);
u32 nPhyInput =0 ,nPhyOutput=0;
-
frames = new Frames(head->dsp_buffer_num[dsp_index]);
do {
@@ -140,7 +149,7 @@
mList.push_back(m);
if(pmod->mID >= mModuleIndex.size()) {
- mModuleIndex.resize(pmod->mID + 1,0);
+ mModuleIndex.resize(pmod->mID + 1, 0);
}
mModuleIndex[pmod->mID] = ++mModuleNum ;
@@ -185,24 +194,63 @@
if (size != nbytes) {
dbg_printf("check flowchart some error!\n");
}
- dbg_printf("Phy InputNum %d, Output Num %d\n",nPhyInput,nPhyOutput);
+// dbg_printf("Phy InputNum %d, Output Num %d\n",nPhyInput,nPhyOutput);
SetNumOfChannels(IntDataType::TDM , nPhyInput, nPhyOutput);
return ErrStatus::SUCCESS;
}
+#define DEBUG 0
+#if 1//DEBUG
+ const s8* type_string[ModuleType::PROC_COUNT] = {
+ "none"
+ ,"input"
+ ,"meter"
+ ,"peq"
+ ,"expander"
+ ,"compresser"
+ ,"limiter"
+ ,"mixer"
+ ,"delay"
+ ,"crossover"
+ ,"output"
+ ,"gain"
+ ,"nhs"
+ ,"gain sharing am"
+ ,"agc"
+ ,"aec"
+ ,"ans"
+ ,"sysctrl"
+ ,"shelf"
+ ,"selector"
+ ,"gating am"
+ ,"spl"
+ ,"gating"
+ ,"ducker"
+ ,"reverb"
+ ,"echo"
+ ,"geq"
+ ,"fir"
+ ,"afc"
+ ,"signal gen"
+ ,"pitch"
+ ,"route"
+ ,"dummuy input"
+ ,"dummy output"
+ };
+#endif
ErrStatus ToB::CreateModuleV1(const u8* bin, u32 nbytes)
{
FlowChartHead* head = (FlowChartHead*)bin;
u32 size = sizeof(FlowChartHead);
u16 nPhyInput[IntDataType::COUNT] = { 0,0,0 }, nPhyOutput[IntDataType::COUNT] = { 0,0,0 };
-
+ s32 len =0;
frames = new Frames(head->dsp_buffer_num[dsp_index]);
do {
const Module* pmod = (Module*)(bin+ size); size += sizeof(Module);
const u16* mRxbufID = (u16*)(bin + size); size += pmod->mRxNum * sizeof(u16);
const u16* mTxbufID = (u16*)(bin + size); size += pmod->mTxNum * sizeof(u16);
- PhyPort* mPhyID ;
+ PhyPort* mPhyID;
ubool bInput=ufalse,bOutput=ufalse;
u16 mRxNum = pmod->mRxNum, mTxNum = pmod->mTxNum;
@@ -222,25 +270,30 @@
if (pmod->mDsp != dsp_index) continue;
-#ifdef DEBUG
- dbg_printf("Module ID %d type %d rxnum %d txnum %d. \n",pmod->mID ,pmod->mType, pmod->mRxNum,pmod->mTxNum);
+#if DEBUG
+ //if (PROC_FIR == pmod->mType)
+ printf("Module ID %d type %d %s rxnum %d txnum %d tag %d. \n",pmod->mID ,pmod->mType, type_string[pmod->mType], pmod->mRxNum,pmod->mTxNum,pmod->mTag);
#endif
- IModule* m = CreateBaseModule(pmod->mType,pmod->mTag, mRxNum,mTxNum);
+
+ IModule* m = CreateBaseModule(pmod->mType, pmod->mTag, mRxNum, mTxNum);
if(!m) {
dbg_printf("Module ID Create fail.\n", pmod->mID);
continue;
}
- m->SetModuleInfo(pmod->mID ,pmod->mType,pmod->mTag);
+
+ m->SetModuleInfo(pmod->mID ,pmod->mType, pmod->mTag);
mList.push_back(m);
if(pmod->mID >= mModuleIndex.size()) {
- mModuleIndex.resize(pmod->mID + 1,0);
+ mModuleIndex.resize(pmod->mID + 1, 0);
}
- mModuleIndex[pmod->mID] = ++mModuleNum ;
+ mModuleIndex[pmod->mID] = ++mModuleNum;
+// printf("Module id:%d, Tx buffer id:", pmod->mID);
for (size_t i = 0; i < mTxNum && !bOutput; i++){
+// printf("bid %d, ", mTxbufID[i]);
if (mTxbufID[i] > 0) {
- Frame* pcm = frames->GetFrame(mTxbufID[i]-1 );
+ Frame* pcm = frames->GetFrame(mTxbufID[i]-1);
m->SetOutputChannelDataPtr(i, pcm);
if (bInput && mPhyID[i].mIntType < IntDataType::COUNT) {
@@ -248,13 +301,16 @@
nPhyInput[mPhyID[i].mIntType] = mPhyID[i].mPhyID;
m->SetInputChannelDataPtr(i, pcm);
SetRxChannelPtr(static_cast<IntDataType>(mPhyID[i].mIntType), mPhyID[i].mPhyID-1, pcm->Data());
+// printf("phy_id %d\n", mPhyID[i].mPhyID);
}
}
else {
m->SetOutputChannelDataPtr(i, 0);
}
}
+// printf(";Rx buffer id:");
for (size_t i = 0; i < mRxNum && !bInput; i++) {
+// printf("mID %d,bid %d\n", pmod->mID, mRxbufID[i]);
if (mRxbufID[i] > 0) {
Frame* pcm = frames->GetFrame(mRxbufID[i]-1 );
m->SetInputChannelDataPtr(i, pcm);
@@ -263,18 +319,41 @@
if(nPhyOutput[mPhyID[i].mIntType] < mPhyID[i].mPhyID)
nPhyOutput[mPhyID[i].mIntType] = mPhyID[i].mPhyID;
- pcm = frames->AllocFrame();
+ //pcm = frames->AllocFrame(); // It is not necessary to be compatible with the AXE1208 series here, because the TOP architecture is different.
m->SetOutputChannelDataPtr(i, pcm);
SetTxChannelPtr(static_cast<IntDataType>(mPhyID[i].mIntType), mPhyID[i].mPhyID-1, pcm->Data());
+// printf("mID %d,bid %d\n", pmod->mID, mPhyID[i].mPhyID-1);
+// printf("phy_type %d, _id %d\n", mPhyID[i].mIntType, mPhyID[i].mPhyID);
}
}
else {
m->SetInputChannelDataPtr(i, 0);
}
}
+// printf("\n");
m->Init();
+
+ // 从 paramset 中获取对应的参数控制函数指针
+ ParamCtrl_fn paramEntry = paramset->GetParamEntry( m->GetModuleType());
+ if(paramEntry == NULL) {
+ printf("paramEntry is NULL!\n");
+ }
+ // 调用参数控制函数
+ u32 result = paramEntry(m, (uvoid*)pmod->mParamaddr, len);
+
} while (size < nbytes);
+
+// int ddr = sram_free_space(SRAM_DDR,mem_any);
+// int ccm = sram_free_space(SRAM_L2,mem_any);
+// int l1 = sram_free_space(SRAM_L1,mem_heap);
+// printf("mListAdd:0x%x, ddr %d ccm %d l1 %d.\n", &mList, ddr, ccm ,l1);
+
+//for (auto pl : mList) {
+// delete pl;
+// int l2mem = sram_free_space(SRAM_L2, mem_any);
+// printf("L2mem %d\n", l2mem);
+//}
if (size != nbytes) {
dbg_printf("check flowchart some error!\n");
@@ -284,6 +363,12 @@
SetNumOfChannels(static_cast<IntDataType>(i) , nPhyInput[i], nPhyOutput[i]);
}
+ /*for (auto pt = mList.begin(); pt < mList.end(); pt++) {
+ IModule *p = *pt._Myptr;
+ static int i = 0;
+ printf("%d, id %d, type %d\n",i++, p->GetModuleID(), p->GetModuleType());
+ }*/
+
return ErrStatus::SUCCESS;
}
ErrStatus ToB::toAnalysis(const u8* bin, u32 nbytes)
@@ -291,14 +376,14 @@
FlowChartHead* head = (FlowChartHead*)bin;
ErrStatus ret = ErrStatus::ERR_METHOD;
//check crc
- u32 tmp_crc ,crc = head->crcLsb|(head->crcMsb<<16);
- head->crcLsb = head->crcMsb = 0;
+ s32 tmp_crc;
+ s32 crc = head->crc;
+ head->crc = 0;
tmp_crc = CRC::crc32(bin, nbytes);
if (tmp_crc != crc) {
- //dbg_printf("flowchar crc check fail.\n");
+ printf("flowchar crc check fail.\n");
return ErrStatus::ERR_PARAM;
}
-
processed = ufalse;
if(head->version == 0) {
@@ -307,16 +392,19 @@
else if(head->version == 1) {
ret = CreateModuleV1(bin, nbytes);
}
-
+ processed = utrue;
return ret;
}
ErrStatus ToB::toProc()
{
if(processed) {
- for (auto iter = mList.begin();
- iter != mList.end() ;iter++) {
- (*iter)->Proc();
+ for (auto iter = mList.begin(); iter < mList.end(); iter++) {
+// if(((*iter)->GetModuleType() >= 6) && ((*iter)->GetModuleType() <= 6)) {
+// printf("%d ", (*iter)->GetModuleID());
+ (*iter)->Proc();
+// }
}
+// printf("\n");
}
else {
MuteOutput();
@@ -336,6 +424,28 @@
return 0;
}
+/*ErrStatus ToB::toCtrl(u32 mID, u32 pID, const s16* val, u32 num)
+{
+ if(mID >= mModuleIndex.size() || mModuleIndex[mID] == 0) {
+ printf("ToB::toCtrl mID Error!\n");
+ return ErrStatus::ERR_PARAM;
+ }
+
+ IModule* m = mList[mModuleIndex[mID]-1];
+ if(!m) {
+ printf("ToB::toCtrl m Error!\n");
+ return ErrStatus::ERR_PARAM;
+ }
+
+ auto entries = paramset->GetEntries(m->GetModuleType());
+ if(!entries.second) {
+ printf("ToB::toCtrl entries Error!\n");
+ return ErrStatus::ERR_METHOD;
+ }
+
+ entries.second(m, pID, const_cast<s16*>(val), num);
+ return ErrStatus::SUCCESS;
+}*/
ErrStatus ToB::toCtrl(u32 mID, u32 pID, const s16* val, u32 num)
{
if(mID >= mModuleIndex.size() || mModuleIndex[mID] == 0) {
@@ -344,9 +454,10 @@
IModule* m = mList[mModuleIndex[mID]-1];
if( m != NULL) {
- m->Ctrl(pID, val, num);
+// m->Ctrl(pID, val, num);
+ paramset->GetCtrlEntry(m->GetModuleType())(m, pID, (s16*)val, num);
}
-
+// printf("mID:%d pID:%d val[0]:%d val[1]:%d\n",mID, pID, val[0], val[1]);
return ErrStatus::SUCCESS;
}
@@ -355,11 +466,11 @@
FlowChartHead* head = (FlowChartHead*)bin;
//check crc
- u32 tmp_crc ,crc = head->crcLsb|(head->crcMsb<<16);
- head->crcLsb = head->crcMsb = 0;
+ u32 tmp_crc ,crc = head->crc;
+ head->crc =0;
tmp_crc = CRC::crc32(bin, nbytes);
if (tmp_crc != crc) {
- //dbg_printf("flowchar crc check fail.\n");
+ dbg_printf("flowchar crc check fail.\n");
return ErrStatus::ERR_PARAM;
}
@@ -375,137 +486,29 @@
}
if(size != nbytes) {
- //dbg_printf("check preset has some error!\n");
+ dbg_printf("check preset has some error!\n");
}
processed = utrue;
return ErrStatus::SUCCESS;
}
-u32 ToB::GetLevels(Message* handle , MSG* pmsg)
+
+u32 ToB::GetLevels(s16* buffer)
{
- u32 n =0,len =0;
- s8 buffer[MSG_DATA_LEN];
- u32 packetNo =0;
+ u32 n =0,size =0;
if( !processed ) {
return 0;
}
-//
-// for (std::vector<IModule*>::iterator iter = mList.begin();
-// iter != mList.end() ; iter++) {
-// IModule* m = *iter;
-//
-// u32 ID = m->GetModuleID();
-//
-// struct Level* p = (struct Level*)buffer;
-//
-// n = sizeof(struct Level);
-// p->mID = ID;
-//
-// /*graydon-230905: 多通道模块会出现电平数量超出1024,比如32通道32点反馈抑制,
-// * ps: 讨论决定多通道模块在界面做数量限制且过多多通道不符合应用需求.
-// */
-// p->num = m->GetLevel((s16*)(buffer + n));
-// if(p->num == 0) continue;
-//
-// n += p->num*sizeof(s16);
-//
-// //过去的电平数量+当前的电平数量是否大于MSG_DATA_LEN
-// if(len + n > MSG_DATA_LEN) {
-// pmsg->pktNo = packetNo++;
-// pmsg->totalPkts = mLevelPacketNum;
-// pmsg->Enc(MsgType::MSG_LEVEL_GET_RES, 0, len);
-// handle->Send(pmsg);//入队列
-// len = 0;
-// }
-// memcpy(pmsg->data+len, p , n);
-// len += n;
-// }
-//
-// if(len > 0) {
-// pmsg->pktNo = packetNo++;
-// pmsg->totalPkts = mLevelPacketNum;
-// pmsg->Enc(MsgType::MSG_LEVEL_GET_RES, 0, len);
-// handle->Send(pmsg);
-// }
-//
-// if(packetNo > 0){
-// mLevelPacketNum = packetNo;
-// }
-// return n;
- return 0;
-}
+ for (std::vector<IModule*>::iterator iter = mList.begin();
+ iter != mList.end() ; iter++) {
+ size = (*iter)->GetLevel(buffer + n );
+// printf("proc %s level num:%d\n",type_string[(*iter)->GetModuleType()],size);
+ n += size;
+ }
-
-//cpu = time*SAMPLE_RATE/SAMPLE_NUM
-//cpu *1000 -> s32
-//cpu * 100 -> percent.
-u32 ToB::GetModuleCPU(Message* handle , MSG* pmsg)
-{
-// u32 n =0;
-// const ufloat period_s = SAMPLE_NUM*1.f/SAMPLE_RATE;
-// const u32 percent = 100000;
-// ufloat module_cpu ;
-// u32* data = (u32*)pmsg->data;
-//
-// if( !processed ) {
-// return 0;
-// }
-//
-// for (std::vector<IModule*>::iterator iter = mList.begin();
-// iter != mList.end() ; iter++) {
-// IModule* m = *iter;
-// ufloat time = m->GetRuntime();
-// ModuleType type = (ModuleType)m->GetModuleType();
-// u32 tag = m->GetModuleTag();
-// u16 rxNum = m->GetModuleInputNum();
-// u16 txNum = m->GetModuleOutputNum();
-// u32 ID = m->GetModuleID();
-//
-//
-// switch(type) {
-// case ModuleType::Mixer:
-// case ModuleType::SupperMatrix:
-// time = time / rxNum ;
-// module_cpu = time / period_s ;
-// break;
-// case ModuleType::GEQ:
-// case ModuleType::EQ:
-// case ModuleType::NHS:
-// time = time / (tag * rxNum) ;
-// module_cpu = time / period_s ;
-// break;
-// case ModuleType::SignalGenerator:
-// case ModuleType::Ducker:
-// case ModuleType::ContinuitySPL:
-// time = time / txNum ;
-// module_cpu = time / period_s ;
-// break;
-// case ModuleType::AEC:
-// module_cpu = time / 0.01f ;//aec 10ms处理一次.
-// break;
-// default:
-// time = time / rxNum ;
-// module_cpu = time / period_s ;
-// break;
-// }
-// data[n++] = ID;
-// data[n++] = (u32)(module_cpu* percent);
-//
-// if(n*sizeof(u32) >= MSG_DATA_LEN) {
-// pmsg->Enc(MsgType::MSG_MODULE_CPU_RES, 0, MSG_DATA_LEN);
-// handle->Send(pmsg);
-// n = 0;
-// }
-// }
-//
-// if(n > 0) {
-// pmsg->Enc(MsgType::MSG_MODULE_CPU_RES, 0, n*sizeof(u32));
-// handle->Send(pmsg);
-// }
-
- return 0;
+ return n;
}
diff --git a/src/tob.h b/src/tob.h
index c1ae2d7..d352905 100644
--- a/src/tob.h
+++ b/src/tob.h
@@ -15,6 +15,7 @@
#include "ModuleExport.h"
#include "messageproc.h"
#include "protocol.h"
+#include "tg/tg_param_ctrl.h"
class ToB {
@@ -22,19 +23,25 @@
std::vector<IModule*> mList;//模块列表
std::vector<u16> mModuleIndex;
+ param_ctrl_t* paramset;
Frames* frames;
u32 dsp_index;
ubool dual_dsp;
ubool processed;
u16 mModuleNum;
- u16 mLevelPacketNum ;
IModule* CreateBaseModule( u32 moduleType, u16 tag, u16 rxNum, u16 txNum);
ErrStatus CreateModule(const u8* bin, u32 nbytes);
ErrStatus CreateModuleV1(const u8* bin, u32 nbytes);
public:
ToB(ubool dualDsp, u32 dspIndex);
~ToB();
- static ToB* GetInstance();
+// static ToB* GetInstance();
+ ToB(const ToB&) = delete;
+ ToB& operator=(const ToB&) = delete;
+ static ToB* GetInstance(ubool dualDsp = true, u32 dspIndex = 0) {
+ static ToB instance(dualDsp, dspIndex);
+ return &instance;
+ }
uvoid SetMute(ubool mute);
ErrStatus toClear();
ErrStatus toProc();
@@ -42,10 +49,9 @@
ErrStatus toCtrl(u32 mID, u32 pID, const s16* val, u32 num);
ErrStatus toCtrl(const u8* bin , u32 nbytes);
ErrStatus toAnalysis(const u8* bin, u32 nbytes);
- u32 GetLevels(Message* handle , MSG* msg);
- u32 GetModuleCPU(Message* handle , MSG* pmsg);
+ u32 GetLevels(s16* buffer);
u16 GetModuleNum() {return mModuleNum;}
- u16 GetLevelPacketNum() {return mLevelPacketNum;}
+
u32 GetDSPIndex(){return dsp_index ;}
u32 GetModuleType(u32 mID);
};
diff --git a/system.svc b/system.svc
deleted file mode 100644
index 267aec3..0000000
--- a/system.svc
+++ /dev/null
@@ -1,113 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<root>
- <installedComponents>
- <component id="com.analog.sourcegen.component.startup_ldf" name="Startup Code/LDF" version="1.0.0" visible="true">
- <component-description><![CDATA[This component provides the ability to generate Startup Code and LDF source files. Startup code is a procedure that initializes and configures the processor when execution jumps to the "start" address on reset.
-It sets the machine into a known state, initializes selected features, and enables the standard runtime-model.
-A Linker Description File (LDF) defines the target memory map and the placement of program sections within processor memory.
-It provides information needed to link your code. It can be used to configure memory related options, such as the placement of the system heap, system stack, and external memory.]]></component-description>
- <product name="Startup Code/LDF" version="1.0.0"/>
- </component>
- </installedComponents>
- <configurations>
- <configuration id="com.analog.sourcegen.component.startup_ldf">
- <startup_ldf-configuration>
- <crt_and_ldf>
- <propertygroup name="mandatory">
- <property name="si_revision" value="0.0"/>
- <property name="ivt_output" value="app_IVT.s"/>
- <property name="processor" value="ADSP-21569"/>
- <property name="product_name" value="CrossCore(R) Embedded Studio"/>
- <property name="crt_doj" value="app_startup.doj"/>
- <property name="crt_output" value="app_startup.s"/>
- <property name="ldf_output" value="app.ldf"/>
- </propertygroup>
- <propertygroup name="template_schemas" value="true">
- <property name="ldf_schema" value="29.07"/>
- <property name="startup_code_schema" value="211.03"/>
- </propertygroup>
- <crt>
- <propertygroup name="cplb_init" value="true">
- <property name="cplb_src_file" value="app_cplbtab.c"/>
- <property name="cplb_ctrl" value="57"/>
- <property name="cplb_obj_file" value="app_cplbtab.doj"/>
- <property name="cplb_src_alt" value="false"/>
- </propertygroup>
- <propertygroup name="mem_init" value="false"/>
- <propertygroup name="use_multicores" value="1">
- <property name="use_core" value="0"/>
- </propertygroup>
- <property name="main_never_returns" value="false"/>
- <property name="use_mt" value="false"/>
- <property name="init_regs" value="false"/>
- <property name="zero_return_regs" value="false"/>
- <property name="using_cplusplus" value="true"/>
- <property name="use_argv" value="false"/>
- <property name="use_profiling" value="false"/>
- <property name="use_default_handlers" value="false"/>
- <property name="use_user_mod_crt" value="true"/>
- <property name="use_custom_vector" value="false"/>
- <property name="dcache_config" value="disable_dcache_and_enable_cplb"/>
- <property name="detect_stackoverflow" value="false"/>
- <property name="device_init" value="true"/>
- <property name="icache_config" value="enable_icache"/>
- </crt>
- <ldf>
- <propertygroup name="system_heap" value="L2">
- <property name="min_size" value="1000"/>
- <property name="size_units" value="kB"/>
- <property name="customized" value="true"/>
- </propertygroup>
- <propertygroup name="system_stack" value="L1">
- <property name="size_units" value="kB"/>
- <property name="customized" value="true"/>
- <property name="min_size" value="32"/>
- </propertygroup>
- <propertygroup name="use_sdram" value="true">
- <property name="partitioned" value="default"/>
- <property name="size" value="256"/>
- <property name="size_units" value="MegaBytes"/>
- <property name="dmc_size_0" value="256"/>
- </propertygroup>
- <propertygroup name="running_from_internal_memory" value="true"/>
- <propertygroup name="libraries" value="true">
- <property name="heap_dbg_libs" value="false"/>
- <property name="no_libdrv" value="false"/>
- <property name="use_eh_enabled_libs" value="false"/>
- <property name="use_fixed_point_io_libs" value="false"/>
- <property name="use_fileio_libs" value="false"/>
- <property name="use_alt_io_lib" value="false"/>
- </propertygroup>
- <propertygroup name="user_heap_DDRHeap" value="L3">
- <property name="size_units" value="MB"/>
- <property name="heap_name" value="DDRHeap"/>
- <property name="heap_id" value="1"/>
- <property name="min_size" value="128"/>
- </propertygroup>
- <property name="use_eh" value="true"/>
- <property name="user_heap_src_file" value="app_heaptab.c"/>
- <property name="use_full_cpplib" value="false"/>
- <property name="use_software_modules" value="false"/>
- <property name="use_user_mod_ldf" value="true"/>
- <property name="use_pgo_hw" value="false"/>
- </ldf>
- </crt_and_ldf>
- <sharc_caches>
- <propertygroup name="icache" value="true">
- <property name="disabled" value="false"/>
- <property name="size_in_KB" value="16"/>
- </propertygroup>
- <propertygroup name="pmcache" value="true">
- <property name="disabled" value="false"/>
- <property name="size_in_KB" value="32"/>
- </propertygroup>
- <propertygroup name="dmcache" value="true">
- <property name="disabled" value="false"/>
- <property name="size_in_KB" value="64"/>
- </propertygroup>
- <propertygroup name="cache_ranges" value="true"/>
- </sharc_caches>
- </startup_ldf-configuration>
- </configuration>
- </configurations>
-</root>
diff --git a/system/startup_ldf/app.ldf b/system/startup_ldf/app.ldf
index ad87259..159dc57 100644
--- a/system/startup_ldf/app.ldf
+++ b/system/startup_ldf/app.ldf
@@ -1,8 +1,8 @@
/*
-** ADSP-21569 linker description file generated on Jul 17, 2025 at 13:46:52.
+** ADSP-21569 linker description file generated on Sep 05, 2025 at 15:48:19.
*/
/*
-** Copyright (C) 2000-2022 Analog Devices Inc., All Rights Reserved.
+** Copyright (C) 2000-2023 Analog Devices Inc., All Rights Reserved.
**
** This file is generated automatically based upon the options selected
** in the System Configuration utility. Changes to the LDF configuration
@@ -15,7 +15,7 @@
** placed within these sections are preserved when this file is re-generated.
**
** Product : CrossCore Embedded Studio
-** Tool Version : 6.2.3.3
+** Tool Version : 6.2.5.2
*/
ARCHITECTURE(ADSP-21569)
@@ -273,7 +273,7 @@
// Stack and heap initial memory reserve.
dxe_block0_stack_and_heap_reserve NO_INIT BW
{
- RESERVE(heaps_and_system_stack_in_L1, heaps_and_system_stack_in_L1_length = 32768, 8)
+ RESERVE(heaps_and_system_stack_in_L1, heaps_and_system_stack_in_L1_length = 189440, 8)
} > mem_block0_bw
// Highest priority (prio0) data and code.
@@ -1594,8 +1594,11 @@
INPUT_SECTION_ALIGN(4)
RESERVE_EXPAND(heaps_and_system_stack_in_L1, heaps_and_system_stack_in_L1_length, 0, 8)
ldf_stack_space = heaps_and_system_stack_in_L1;
- ldf_stack_end = (ldf_stack_space + (heaps_and_system_stack_in_L1_length - 8));
+ ldf_stack_end = (ldf_stack_space + (((heaps_and_system_stack_in_L1_length * 57344) / 189440) - 8));
ldf_stack_length = ldf_stack_end - ldf_stack_space;
+ L1mem_space = ldf_stack_end + 8;
+ L1mem_end = (L1mem_space + (((heaps_and_system_stack_in_L1_length * 132096) / 189440) - 8));
+ L1mem_length = L1mem_end - L1mem_space;
} > mem_block0_bw
dxe_l2_stack_and_heap_expand NO_INIT BW
@@ -1620,7 +1623,7 @@
/*$VDSG<insert-input-sections-at-the-start-of-dxe_sdram_stack_and_heap> */
RESERVE_EXPAND(heaps_and_system_stack_in_L3, heaps_and_system_stack_in_L3_length, 0, 8)
- DDRHeap_space = heaps_and_system_stack_in_L3;
+ DDRHeap_space = heaps_and_system_stack_in_L3 + 8;
DDRHeap_end = (DDRHeap_space + (heaps_and_system_stack_in_L3_length - 8));
DDRHeap_length = DDRHeap_end - DDRHeap_space;
} > SDRAM_STACK_HEAP_BLOCK
diff --git a/system/startup_ldf/app_IVT.s b/system/startup_ldf/app_IVT.s
index 0752e5d..6f9bb92 100644
--- a/system/startup_ldf/app_IVT.s
+++ b/system/startup_ldf/app_IVT.s
@@ -1,8 +1,8 @@
/*
-** ADSP-21569 app_IVT.s generated on Jul 17, 2025 at 13:46:52
+** ADSP-21569 app_IVT.s generated on Sep 05, 2025 at 15:48:19
*/
/*
-** Copyright (C) 2000-2022 Analog Devices Inc., All Rights Reserved.
+** Copyright (C) 2000-2023 Analog Devices Inc., All Rights Reserved.
**
** This file is generated automatically based upon the options selected
** in the System Configuration utility. Changes to the Startup Code configuration
diff --git a/system/startup_ldf/app_heaptab.c b/system/startup_ldf/app_heaptab.c
index 45be006..57e0445 100644
--- a/system/startup_ldf/app_heaptab.c
+++ b/system/startup_ldf/app_heaptab.c
@@ -1,8 +1,8 @@
/*
-** ADSP-21569 user heap source file generated on Jul 17, 2025 at 13:46:52.
+** ADSP-21569 user heap source file generated on Sep 05, 2025 at 15:48:19.
*/
/*
-** Copyright (C) 2000-2022 Analog Devices Inc., All Rights Reserved.
+** Copyright (C) 2000-2023 Analog Devices Inc., All Rights Reserved.
**
** This file is generated automatically based upon the options selected
** in the System Configuration utility. Changes to the Heap configuration
@@ -15,7 +15,7 @@
** placed within these sections are preserved when this file is re-generated.
**
** Product : CrossCore Embedded Studio
-** Tool Version : 6.2.3.3
+** Tool Version : 6.2.5.2
*/
#ifdef _MISRA_RULES
@@ -34,14 +34,17 @@
extern "asm" unsigned long ldf_heap_space;
extern "asm" unsigned long ldf_heap_length;
+extern "asm" int L1mem_space;
+extern "asm" int L1mem_length;
extern "asm" int DDRHeap_space;
extern "asm" int DDRHeap_length;
-const __heap_desc_t heap_table[3] =
+const __heap_desc_t heap_table[4] =
{
{ &ldf_heap_space, (unsigned long) &ldf_heap_length, 0 },
- { &DDRHeap_space, (unsigned long) &DDRHeap_length, 1 },
+ { &L1mem_space, (unsigned long) &L1mem_length, 1 },
+ { &DDRHeap_space, (unsigned long) &DDRHeap_length, 2 },
{ (void *)0, (size_t)0, 0 } /* This terminates the table. */
};
diff --git a/system/startup_ldf/app_startup.s b/system/startup_ldf/app_startup.s
index deb1ceb..7bdee73 100644
--- a/system/startup_ldf/app_startup.s
+++ b/system/startup_ldf/app_startup.s
@@ -1,8 +1,8 @@
/*
-** ADSP-21569 startup code generated on Jul 17, 2025 at 13:46:52.
+** ADSP-21569 startup code generated on Sep 05, 2025 at 15:48:19.
*/
/*
-** Copyright (C) 2000-2022 Analog Devices Inc., All Rights Reserved.
+** Copyright (C) 2000-2023 Analog Devices Inc., All Rights Reserved.
**
** This file is generated automatically based upon the options selected
** in the System Configuration utility. Changes to the Startup Code configuration
@@ -15,7 +15,7 @@
** placed within these sections are preserved when this file is re-generated.
**
** Product : CrossCore Embedded Studio
-** Tool Version : 6.2.3.3
+** Tool Version : 6.2.5.2
*/
.FILE_ATTR libGroup="startup";
--
Gitblit v1.9.3