Signed-off-by: chenlh <2008get@163.com>
| | |
| | | }ADI_DMC_CONFIG; |
| | | |
| | | int dmc_cfg0_init(void); |
| | | void adi_dmc_lane_reset(bool reset); |
| | | |
| | | #ifdef __cplusplus |
| | | } |
| | |
| | | #include "linkport.h" |
| | | |
| | | |
| | | unsigned int SAMPLE_RATE = 48000; |
| | | unsigned int SAMPLE_NUM = 64; |
| | | |
| | | |
| | | void spu_config(void) |
| | | { |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | * Author: graydon |
| | | */ |
| | | |
| | | #ifndef DRV_BOARD_H_ |
| | | #define DRV_BOARD_H_ |
| | | //#ifndef DRV_BOARD_H_ |
| | | //#define DRV_BOARD_H_ |
| | | #pragma once |
| | | |
| | | #ifdef __cplusplus |
| | | extern "C" { |
| | |
| | | |
| | | #include "typedefs.h" |
| | | #include "sru_dai.h" |
| | | |
| | | extern unsigned int SAMPLE_RATE; |
| | | extern unsigned int SAMPLE_NUM; |
| | | |
| | | /* |
| | | * 为了和21489 保持兼容, 协议定义全部采用short类型 |
| | | * */ |
| | |
| | | #ifdef __cplusplus |
| | | } |
| | | #endif |
| | | #endif /* DRV_BOARD_H_ */ |
| | | //#endif /* DRV_BOARD_H_ */ |
| | |
| | | #include <stdint.h> |
| | | #include <stdlib.h> |
| | | #include <services/pwr/adi_pwr.h> |
| | | #include "DMCInit.h" |
| | | |
| | | /********************************************************************************************** |
| | | * CGU Configuration Number 0 |
| | |
| | | #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 |
| | |
| | | |
| | | // 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; |
| | |
| | | *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); |
| | |
| | | *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); |
| | |
| | | *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); |
| | |
| | | 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,... |
| | |
| | | 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) { |
| | |
| | | |
| | | 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 |
| | | } |
| | |
| | | #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 |
| | |
| | | |
| | | #define LEVEL_REPORT_TIME(x) \ |
| | | (x*SAMPLE_RATE/(1000*SAMPLE_NUM)) |
| | | #endif |
| | | |
| | | |
| | | //#endif |
| | | |
| | | |
| | |
| | | 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_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, |
| | |
| | | #include <string.h> |
| | | #include <math.h> |
| | | #include "config.h" |
| | | #include "f2f.h" |
| | | #include "../drv/sport.h" |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | 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]; |
| | |
| | | |
| | | 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); |
| | |
| | | |
| | | 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{ |
| | |
| | | #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 |
| | |
| | | GPIO_SetOutPut(GPIOB, GPIO_Pin10, level); |
| | | } |
| | | |
| | | |
| | | /* |
| | | * 128 · |
| | | UpdateInput && UpdateOutput 7.37% |
| | |
| | | * */ |
| | | 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(); |
| | | ModulesAsynSetInterval(proc_secs); |
| | | fir_acc_startup(); |
| | | // ModulesAsynSetInterval(proc_secs); |
| | | // fir_acc_startup(); |
| | | clock_stop = clock(); |
| | | proc_secs = ((ufloat) (clock_stop - clock_start))/ CLOCKS_PER_SEC; |
| | | } |
| | |
| | | UpdateInput(iid, DMACount[iid]&0x1); |
| | | UpdateOutput(iid, DMACount[iid]&0x1); |
| | | } |
| | | |
| | | DMACount[iid]++; |
| | | } |
| | | |
| | |
| | | |
| | | //通知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. |
| | | //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); |
| | | |
| | | u32 ddrspace = sram_free_space(SRAM_DDR, mem_any); |
| | | printf("ddrspace:%d\n", ddrspace); |
| | | |
| | | while(1) { |
| | | asyn_proc_secs = ModulesAsynProcess(); |
| | |
| | | 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); |
| | | } |
| | |
| | | } |
| | | loop_cnt =0; |
| | | clock_check_count = DMACount[var.master_intr]; |
| | | printf("clk1 ok\n"); |
| | | } |
| | | |
| | | |
| | |
| | | spiMsg->DspStatusPush(DSP_CLOCK_STATUS, 0, 0); |
| | | request_topo_count = DMACount[var.master_intr] ; |
| | | var.clock_ok = utrue; |
| | | printf("clk2 ok\n"); |
| | | } |
| | | } |
| | | |
| | |
| | | /* |
| | | * messageproc.c |
| | | * |
| | | * Created on: 2021年11月1日 |
| | | * Created on: 2021年11月1日 |
| | | * Author: graydon |
| | | */ |
| | | #include <string.h> |
| | |
| | | #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" |
| | |
| | | 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); |
| | | u32 msgLen = LevelCnt * sizeof(*Levels); |
| | | |
| | | int Packegs = (LevelCnt+MSG_DATA_LEN-1)/MSG_DATA_LEN; |
| | | |
| | | pmsg->magic = 0x5aa5; |
| | | // pmsg->dataLen = LevelCnt; |
| | | pmsg->totalPkts = Packegs; |
| | | // pmsg->pktNo = 1; |
| | | pmsg->msgType = MSG_GET_LEVEL; |
| | | |
| | | // 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, data_len); |
| | | pmsg->dataLen = LevelCnt; |
| | | pmsg->pktNo = i; |
| | | |
| | | pmsg->Enc(MsgType::MSG_GET_LEVEL, 0, msgLen); |
| | | txQueue->Push(*pmsg); |
| | | } |
| | | } |
| | |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | s32 Message::PresetProcess(MSG* pmsg) |
| | | { |
| | | VarState& var = VarState::GetInstance(); |
| | |
| | | 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); |
| | | } |
| | | 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; |
| | | |
| | |
| | | var.TopoStatus = PRESET_STA::PRESET_ERR; |
| | | } |
| | | else if(tob){ |
| | | s8* content = (s8*)sram_malloc(SRAM_DDR, mem_any ,16*1024); |
| | | u8* content = (u8*)sram_malloc(SRAM_DDR, mem_any, 45128);//45*1024); |
| | | s32 size ; |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /*void Message::param_init(ptag_device_config pDevCfg) |
| | | { |
| | | pDevCfg->dual_dsp = 0; |
| | | pDevCfg->dsp_index = 0; |
| | | pDevCfg->local_rx_num = 16; |
| | | pDevCfg->local_tx_num = 16; |
| | | pDevCfg->dante_rx_num = 16; |
| | | pDevCfg->dante_tx_num = 16; |
| | | pDevCfg->external_clock = 1; |
| | | pDevCfg->scene_size = 1000; |
| | | pDevCfg->level_num = 10; |
| | | pDevCfg->modulelist = 9; |
| | | pDevCfg->hardware_type = 1; |
| | | |
| | | }*/ |
| | | |
| | | s32 Message::HandshakeMessageProcess(MSG* pmsg) |
| | | { |
| | |
| | | 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; |
| | | } |
| | | |
| | | // 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 tgScene(_adapter); |
| | | 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; |
| | |
| | | ParamCtrl(pmsg); |
| | | break; |
| | | case MsgType::MSG_GET_LEVEL: |
| | | //ReportLevel(pmsg); |
| | | break; |
| | | case MsgType::MSG_PARAM_CONFIG: |
| | | case MsgType::MSG_PARAM_COMPLETED: |
| | |
| | | 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); |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | #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); |
| | | |
| | |
| | | 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(SRAM_DDR) s16[300]; |
| | | } |
| | | ~Message() |
| | | { |
| | |
| | | uvoid Proc(); |
| | | |
| | | uvoid ReportDspStatus(MSG* pmsg); |
| | | uvoid ReportLevel(MSG* pmsg); |
| | | }; |
| | | |
| | | #endif /* MESSAGEPROC_H_ */ |
| | |
| | | #ifndef PROTOCOL_H_ |
| | | #define PROTOCOL_H_ |
| | | |
| | | #include <string> |
| | | #include "config.h" |
| | | |
| | | #define MSG_DATA_LEN (SPI_BUFFER_SIZE-16) |
| | |
| | | }PhyPort; |
| | | |
| | | struct FlowChartHead { |
| | | short crcLsb; |
| | | short crcMsb; |
| | | int crc; |
| | | unsigned short module_num; |
| | | unsigned char compress; |
| | | unsigned char version; |
| | |
| | | * Created on: 2025年7月21日 |
| | | * Author: 86189 |
| | | */ |
| | | #include <stdio.h> |
| | | #include <cstdlib> |
| | | #include <cstring> |
| | | #include "config.h" |
| | |
| | | #include "moduleexport.h" |
| | | #include "crc.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; |
| | |
| | | |
| | | ptr = strtok(NULL, "-"); |
| | | end = atoi(ptr); |
| | | if(start==end) return 0; |
| | | while (start<=end) |
| | | { |
| | | logic_channel[i++] = start++; |
| | |
| | | |
| | | |
| | | |
| | | 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]; |
| | | |
| | | u16 dsp_input_num[2] ={0,0}; |
| | | u16 dsp_output_num[2] ={0,0}; |
| | | |
| | | s32 crc = 0xFFFFFFFF; |
| | | |
| | | if (!bin) return 0; |
| | | |
| | | for (i=0; i< proc_list.size(); i++) { |
| | | struct Module *m = (struct Module *)(bin + size); |
| | | struct proc_field * p = &proc_list[i]; |
| | | printf("proc list size %d\n", proc_list.size()); |
| | | |
| | | for (i=0; i< proc_list.size(); 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) ; |
| | |
| | | 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; |
| | |
| | | } |
| | | } |
| | | |
| | | m->mDsp = p->dsp_index; |
| | | m->mDsp = hw_adapter->get_system_is_dual_dsp()?p->dsp_index:0; |
| | | m->mID = p->proc_id; |
| | | m->mType = p->proc_type; |
| | | m->mTag = p->tag; |
| | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | //解析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 u32 get_module_id(u32 mid, s32 mtype ,u32 pid) =0; |
| | | |
| | | s32 convert_to_bin(s8* bin); |
| | | s32 convert_to_bin(u8* bin); |
| | | }; |
| | | |
| | | #endif |
| | |
| | | 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{ |
| | |
| | | } |
| | | else if(logic_channel < input_num) { |
| | | //dante |
| | | return 17+ (logic_channel-ana_input_num); |
| | | return 19 + (logic_channel-ana_input_num); |
| | | } |
| | | else { |
| | | //usb |
| | | return 49 + (logic_channel-input_num); |
| | | return 17 + (logic_channel-input_num); |
| | | } |
| | | } |
| | | else { |
| | |
| | | return logic_channel +1; |
| | | } |
| | | else if(logic_channel < output_num) { |
| | | return 17+ (logic_channel-ana_output_num); |
| | | return 19 + (logic_channel-ana_output_num); |
| | | } |
| | | else { |
| | | return 49 + (logic_channel-output_num); |
| | | return 17 + (logic_channel-output_num); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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].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; |
| | | conf->sports[4].rx = utrue; |
| | | |
| | | //USB pcg. |
| | | conf->pcgs[1].enable = utrue; |
| | | conf->pcgs[1].opmode = 0; |
| | | 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); |
| | | // conf->pcgs[1].enable = utrue; |
| | | // conf->pcgs[1].opmode = 0; |
| | | // 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); |
| | | |
| | | 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::LOGIC_HIGH, DestSignal::DAI0_PBEN10_I); |
| | | AddRoute(SourceSignal::SPT2_BD0_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 = 16; |
| | | conf->sports[i].vld = 16; |
| | | 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; |
| | |
| | | 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);*/ |
| | | } |
| | |
| | | } |
| | | |
| | | // |
| | | 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__ */ |
| | |
| | | |
| | | 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; |
| | | output_num = ana_output_num + dante_output_num; |
| | | |
| | | //port from 1 start. |
| | | 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); |
| | | __MADD(298,PROC_METER,inport_str,"",0,1 ,NULL,0, ModuleInterfaceType::SOFT_MODULE); //tag:0-peak,1-rms |
| | |
| | | //mixer |
| | | sprintf(inport_str, "1-%d", input_num+ 4); |
| | | sprintf(outport_str, "1-%d", output_num+1); |
| | | __MADD(166,PROC_MIXER,"0-35","0-32",1, 1 ,¶meters.mixer, 0, ModuleInterfaceType::SOFT_MODULE); |
| | | __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++) { |
| | |
| | | __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); |
| | | |
| | | printf("lst size=%d\n", proc_list.size()); |
| | | }; |
| | | |
| | | |
| | | 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: |
| | | 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. |
| | | if(pp->magic != 0xbcba || size != sizeof(tag_parameters)) { |
| | | printf("preset param error!\n"); |
| | | return -1; |
| | | } |
| | | memcpy(¶meters, param, sizeof(tag_parameters)); |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | s32 tgScene::update_module() |
| | | { |
| | | u8 port_number[16]; |
| | | s8 ana_input_num, ana_output_num,dante_input_num,dante_output_num ; |
| | | s16 input_num, output_num ; |
| | | s16 dual_dsp = hw_adapter->get_system_is_dual_dsp(); |
| | |
| | | |
| | | hw_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; |
| | | output_num = ana_output_num + dante_output_num; |
| | | |
| | | for(auto& iter: proc_list){ |
| | | //update dynamic module info. |
| | |
| | | |
| | | #include <vector> |
| | | #include "../scene.h" |
| | | #include "../protocol.h" |
| | | #include "module_def.h" |
| | | |
| | | |
| | | typedef struct { |
| | | unsigned short magic; |
| | |
| | | unsigned short crc[2]; |
| | | |
| | | |
| | | tag_input input;//514 |
| | | tag_input input;//1282 |
| | | |
| | | tag_module in1[MAX_INPUT_NUM]; |
| | | tag_module in2[MAX_INPUT_NUM]; |
| | |
| | | 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 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_ */ |
| | |
| | | */ |
| | | #include <stdlib.h> |
| | | #include <stdio.h> |
| | | #include <heapnew> |
| | | #include "tob.h" |
| | | #include "crc.h" |
| | | #include "config.h" |
| | |
| | | processed = ufalse; |
| | | mModuleNum =0; |
| | | mModuleIndex.resize(0); |
| | | paramset = new tg_param_ctrl_t(); |
| | | paramset = new(SRAM_DDR) tg_param_ctrl_t(); |
| | | } |
| | | |
| | | ToB::~ToB() |
| | |
| | | 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]); |
| | | frames = new Frames(head->dsp_buffer_num[dsp_index]); // C H G |
| | | |
| | | do { |
| | | const Module* pmod = (Module*)(bin+ size); size += sizeof(Module); |
| | |
| | | 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); |
| | | printf("Module ID %d type %d rxnum %d txnum %d tag %d. \n",pmod->mID ,pmod->mType, pmod->mRxNum,pmod->mTxNum,pmod->mTag); |
| | | #endif |
| | | 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); |
| | | mList.push_back(m); |
| | | |
| | |
| | | } |
| | | 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 ); |
| | | m->SetOutputChannelDataPtr(i, pcm); |
| | |
| | | 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", mPhyID[i].mPhyID); |
| | | } |
| | | } |
| | | else { |
| | | m->SetOutputChannelDataPtr(i, 0); |
| | | } |
| | | } |
| | | // printf(";Rx buffer id:"); |
| | | for (size_t i = 0; i < mRxNum && !bInput; i++) { |
| | | // printf("bid %d", mRxbufID[i]); |
| | | if (mRxbufID[i] > 0) { |
| | | Frame* pcm = frames->GetFrame(mRxbufID[i]-1 ); |
| | | m->SetInputChannelDataPtr(i, pcm); |
| | |
| | | pcm = frames->AllocFrame(); |
| | | m->SetOutputChannelDataPtr(i, pcm); |
| | | SetTxChannelPtr(static_cast<IntDataType>(mPhyID[i].mIntType), mPhyID[i].mPhyID-1, pcm->Data()); |
| | | // printf("phy_id %d", mPhyID[i].mPhyID); |
| | | } |
| | | } |
| | | else { |
| | | m->SetInputChannelDataPtr(i, 0); |
| | | } |
| | | } |
| | | // printf("\n"); |
| | | |
| | | m->Init(); |
| | | paramset->GetParamEntry(m->GetModuleType())(m, (uvoid*)pmod->mParamaddr, len); |
| | | //paramset->GetParamEntry(m->GetModuleType())(m, (uvoid*)pmod->mParamaddr, len); |
| | | } while (size < nbytes); |
| | | |
| | | if (size != nbytes) { |
| | |
| | | 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) |
| | |
| | | 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) { |
| | |
| | | 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++) { |
| | | for (auto iter = mList.begin(); iter < mList.end(); iter++) { |
| | | // if ((*iter)->GetModuleID() == 166) |
| | | // continue; |
| | | |
| | | if((*iter)->GetModuleType() <= 5) { |
| | | printf("%d ", (*iter)->GetModuleID()); |
| | | (*iter)->Proc(); |
| | | } |
| | | } |
| | | // printf("\n"); |
| | | } |
| | | else { |
| | | MuteOutput(); |
| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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(s16* buffer) |
| | | { |
| | | u32 n =0,size =0; |
| | |
| | | #include "protocol.h" |
| | | #include "tg/tg_param_ctrl.h" |
| | | |
| | | |
| | | class ToB { |
| | | private : |
| | | std::vector<IModule*> mList;//模块列表 |
| | | std::vector<u16> mModuleIndex; |
| | | |
| | | param_ctrl_t* paramset; |
| | | Frames* frames; |
| | | u32 dsp_index; |