分支自 DSP/ADSP21569/DSP-21569

graydon
2024-02-28 420778fcee054257d540cf24fbf1b1e3f9fc0d9f
合并近期修改。
已修改11个文件
119 ■■■■ 文件已修改
drv/board.c 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
drv/spi.c 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/ModuleProcLibs.dlb 补丁 | 查看 | 原始文档 | blame | 历史
lib/aer.dlb 补丁 | 查看 | 原始文档 | blame | 历史
src/ModuleExport.cpp 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/ModuleExport.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/f2f.c 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.cpp 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/messageproc.cpp 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/protocol.h 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tob.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
drv/board.c
@@ -5,7 +5,6 @@
 *      Author: graydon
 */
#include <stdio.h>
#include <drivers/spi/adi_spi.h>
#include <services/int/adi_int.h>
#include <services/spu/adi_spu.h>
#include <services/pwr/adi_pwr.h>
drv/spi.c
@@ -21,33 +21,44 @@
#define MSIZE 0
#define PSIZE 0
volatile unsigned char     SPI_Tx_BUFFER[SPI_BUFFER_SIZE];
volatile unsigned char     SPI_Rx_BUFFER[SPI_BUFFER_SIZE];
ADI_CACHE_ALIGN volatile unsigned char     SPI_Tx_BUFFER[SPI_BUFFER_SIZE];
ADI_CACHE_ALIGN volatile unsigned char     SPI_Rx_BUFFER[SPI_BUFFER_SIZE];
//
volatile short SPIRxDone =1;
volatile short SPITxDone =1;
volatile unsigned short SPIRxCnt =0, SPITxCnt=0;
static void SPIDMA_Handler(uint32_t iid, void* arg)
{
    if(iid == INTR_SPI2_RXDMA){
        *pREG_DMA27_STAT |= ENUM_DMA_STAT_IRQDONE ;
        *pREG_DMA26_STAT |= ENUM_DMA_STAT_IRQDONE ;
        GPIO_SetOutPut(GPIOA, GPIO_Pin12|GPIO_Pin13, GPIO_HIGH);
        GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_HIGH);
        GPIO_SetOutPut(GPIOC, GPIO_Pin4|GPIO_Pin7, GPIO_HIGH);
        SPIRxCnt ++ ;
        SPIRxDone = 1;
        SPITxDone = 1;
    }
//    else if(iid == INTR_SPI2_TXDMA) {
//        *pREG_DMA26_STAT |= ENUM_DMA_STAT_IRQDONE ;
//        GPIO_SetOutPut(GPIOC, GPIO_Pin4, GPIO_HIGH);
//        GPIO_SetOutPut(GPIOA, GPIO_Pin12|GPIO_Pin13, GPIO_HIGH);
//        GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_HIGH);
//
//        GPIO_SetOutPut(GPIOC, GPIO_Pin4|GPIO_Pin7, GPIO_HIGH);
//
//        SPITxCnt++;
//        SPITxDone = 1;
//    }
//    adi_int_ClearPending(iid);
    adi_int_ClearPending(iid);
}
static void DMAConfig(SPIStatus status)
{
    adi_osal_EnterCriticalRegion();
    if(status == SPI_TX) {
        *pREG_DMA26_CFG         = (MSIZE<<8) | (PSIZE<<4) | 4 ;
        *pREG_DMA26_XCNT     =     SPI_BUFFER_SIZE;
@@ -68,6 +79,30 @@
        *pREG_SPI2_RXCTL |= (1<<0);
    }
    if(status == SPI_TRX) {
        *pREG_SPI2_CTL =0 ;
        *pREG_SPI2_STAT = 0xffffffff;
        *pREG_DMA26_STAT = 0xffffffff;
        *pREG_DMA27_STAT = 0xffffffff;
        *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_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_CFG       |=     1 ;
        *pREG_SPI2_CTL= (MASTER<<1)|(0<<3)|(CPHA<<4)|(CPOL<<5)|(1<<6)|(1<<8)|(BITS<<9)|(1<<0);
        *pREG_SPI2_TXCTL = (5<<4) | (1<<0);
        *pREG_SPI2_RXCTL = (1<<4) | (1<<0);
    }
    adi_osal_ExitCriticalRegion();
}
void SPI_xfer(int8_t* rx, int8_t* tx, uint32_t len)
@@ -94,7 +129,7 @@
    *pREG_SPI2_CTL = (MASTER<<1)|(0<<3)|(CPHA<<4)|(CPOL<<5)|(1<<6)|(1<<8)|(BITS<<9);
    *pREG_SPI2_TXCTL =  (1<<4);
    *pREG_SPI2_TXCTL =  (5<<4);
    *pREG_SPI2_RXCTL =  (1<<4);
@@ -109,11 +144,10 @@
    //SPI2_SetTransMode(status);
    adi_sec_SetPriority(INTR_SPI2_RXDMA, 44);
    //interruptcb(INTR_SPI2_RXDMA, SPIDMA_Handler);
    //adi_int_InstallHandler(INTR_SPI2_TXDMA, SPIDMA_Handler, 0, true);
    adi_int_InstallHandler(INTR_SPI2_RXDMA, SPIDMA_Handler, 0, true);
    *pREG_SPI2_CTL     |= (1<<0);
    //*pREG_SPI2_CTL     |= (1<<0);
    //*pREG_SPI2_TXCTL |= (1<<0);
    //*pREG_SPI2_RXCTL |= (1<<0);
@@ -146,8 +180,8 @@
        GPIO_SetOutPut(GPIOC, GPIO_Pin7, GPIO_LOW);
        break;
    case SPI_TRX:
        DMAConfig(SPI_TX);SPITxDone = 0 ;
        DMAConfig(SPI_RX);SPIRxDone = 0 ;
        //DMAConfig(SPI_RX);SPIRxDone = 0 ;
        DMAConfig(SPI_TRX);SPITxDone = SPIRxDone = 0 ;
        GPIO_SetOutPut(GPIOA, GPIO_Pin12|GPIO_Pin13, GPIO_LOW);
        GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_LOW);
        GPIO_SetOutPut(GPIOC, GPIO_Pin4|GPIO_Pin7, GPIO_LOW);
lib/ModuleProcLibs.dlb
Binary files differ
lib/aer.dlb
Binary files differ
src/ModuleExport.cpp
@@ -68,6 +68,7 @@
//        modules.push_back(ModuleEntry("Echo", ModuleType::Echo, EchoCreate, utrue));
//        modules.push_back(ModuleEntry("Pitch", ModuleType::Pitch, PitchCreate, utrue));
        modules.push_back(ModuleEntry("UnLooping", ModuleType::UnLooping, DummyCreate, ufalse));
    }
}
src/ModuleExport.h
@@ -67,6 +67,9 @@
    Reverb = 128,     //混响
    Echo,            //回声
    Pitch,          //变音
    //解循环模块
    UnLooping = 256,
};
class ModuleEntry {
src/f2f.c
@@ -87,6 +87,7 @@
}
#define CHANNEL_OF(c) (2*((c)&(codec->slot_num-1))+ (c)/codec->slot_num)
#define OFFSET(j) (j<codec->channel_num?CHANNEL_OF(j): CHANNEL_OF(j-codec->channel_num+codec->slot_num))
/*
 * sec 排列方式: 0,16,1,17,2,18,...,15,31
 */
@@ -103,7 +104,7 @@
            if(codec->enable_sec){
                for(u32 j = 0; channel < mInputNum && j < codec->channel_num*2 ;j ++,channel++) {
                    if(mRxChannel[channel] != NULL)
                        floatData(mRxChannel[channel], dataPtr + CHANNEL_OF(j),codec->slot_num*2, SAMPLE_NUM);
                        floatData(mRxChannel[channel], dataPtr + OFFSET(j),codec->slot_num*2, SAMPLE_NUM);
                }
            }
            else{
@@ -130,7 +131,7 @@
            if(codec->enable_sec){
                for(u32 j = 0; channel < mOutputNum && j < codec->channel_num*2 ;j ++,channel++) {
                    if(mTxChannel[channel] != NULL)
                        fixData(dataPtr + CHANNEL_OF(j), mTxChannel[channel], codec->slot_num*2, SAMPLE_NUM);
                        fixData(dataPtr +OFFSET(j), mTxChannel[channel], codec->slot_num*2, SAMPLE_NUM);
                }
            }
            else{
src/main.cpp
@@ -23,7 +23,8 @@
u32 g_level_report_interval = LEVEL_REPORT_TIME(200);
eErrStatus err_status =DSP_NO_ERR;
u32 g_spiQ_drop_cnt =0;
u8  mDspIndex = 0;
ubool  TopoLoading = ufalse;
ubool  HandShakeSuccesful = ufalse;
src/messageproc.cpp
@@ -27,8 +27,12 @@
s32 Message::Send(MSG* pmsg )
{
    extern u32 g_spiQ_drop_cnt;
    u32 ret=  txQueue->Push(*pmsg);
    if(ret == 0) {
        g_spiQ_drop_cnt++;
        set_error(DSP_SPIQ_OVERRANGE);
    }
    return ret;
}
@@ -36,6 +40,7 @@
{
    static u8* bin = NULL;
    extern ubool  TopoLoading ;
    extern eErrStatus err_status;
    if(pmsg->pktNo == 0 && bin != NULL ) {
        sram_free(SRAM_DDR, bin);
@@ -52,10 +57,14 @@
        u32 size = (pmsg->totalPkts -1)*MSG_DATA_LEN+pmsg->dataLen;
        uLongf realsize = size*10;
        Bytef* uncompress_ptr = (Bytef*)sram_malloc(SRAM_DDR, mem_any ,realsize);
        ErrStatus err = ErrStatus::ERR_PARAM;
        if(uncompress_ptr){
            if(tob && uncompress(uncompress_ptr, &realsize, (Bytef*)bin, size) == Z_OK) {
                tob->toCtrl(uncompress_ptr, realsize);
                err = tob->toCtrl(uncompress_ptr, realsize);
            }
            if(err != ErrStatus::SUCCESS){
                set_error(DSP_PRESET_INVALID);
            }
            sram_free(SRAM_DDR, uncompress_ptr);
        }
@@ -89,6 +98,7 @@
    memcpy(bin+pmsg->pktNo*MSG_DATA_LEN, pmsg->data , pmsg->dataLen);
    if(pmsg->pktNo == pmsg->totalPkts -1) {
        ToB* tob = ToB::GetInstance();
        ErrStatus err = ErrStatus::SUCCESS;
        size = (pmsg->totalPkts -1)*MSG_DATA_LEN+pmsg->dataLen;
        SetTxRxNullBufferPtr();
@@ -96,11 +106,14 @@
        if(tob) {
            tob->toClear();
            tob->CreateModule(bin, size);
            err = tob->CreateModule(bin, size);
        }
        if(err != ErrStatus::SUCCESS) {
            set_error(DSP_TOPO_INVALID);
        }
        sram_free(SRAM_DDR, bin);
        bin = NULL;
        if(TopoRequest) {
            Send(MsgType::MSG_TOPO_RES, 0 ,0) ;
            TopoRequest = ufalse;
@@ -168,11 +181,17 @@
{
    struct DSPStatus* status = (struct DSPStatus*)pmsg->data;
    extern ufloat cpu_utility();
    extern u32 g_spiQ_drop_cnt;
    ToB* tob = ToB::GetInstance();
    status->mCpu =  cpu_utility()*100; //all modules execute time.;
    status->mInternalUnUsedMem = space_unused();
    status->mExternalUnUsedMem = sram_free_space(SRAM_DDR,mem_any);
    status->mDDRPassed = 1;
    status->mSPIQDropCnt = g_spiQ_drop_cnt;
    status->mErrStatus = err_status;
    status->mLevelPacketsNum = tob?tob->GetLevelPacketNum():0;
    status->mModuleCnt = tob?tob->GetModuleNum():0;
    pmsg->Enc(MsgType::MSG_DSP_STATUS_RES, 0, sizeof(struct DSPStatus));
@@ -221,7 +240,7 @@
{
    u32 status = 0;
    if(SPITxDone) {
    if(SPIRxDone) {
        RxMessageHandler((MSG*)SPI_Rx_BUFFER);
        if(txQueue->Count() > 0) {
            txQueue->Pop(*(MSG*)SPI_Tx_BUFFER);
src/protocol.h
@@ -40,6 +40,9 @@
    MSG_MODULE_CPU_REQ,
    MSG_MODULE_CPU_RES,
    MSG_SPI_RESET_REQ,
    MSG_SPI_RESET_RES,
};
@@ -129,13 +132,26 @@
};
typedef enum {
    DSP_NO_ERR,
    DSP_TOPO_INVALID,
    DSP_PRESET_INVALID,
    DSP_NO_TOPO,
    DSP_SPIQ_OVERRANGE,
}eErrStatus;
extern eErrStatus err_status;
#define set_error(err_no) err_status = err_no
struct DSPStatus{
    unsigned int mCpu;
    unsigned int mInternalUnUsedMem;
    unsigned int mExternalUnUsedMem;
    unsigned char mDDRPassed;
    unsigned char pad[3];
    unsigned char mLevelPacketsNum;
    unsigned char mErrStatus;
    unsigned char pad[2];
    unsigned short mSPIQDropCnt;
    unsigned short mModuleCnt;
    //.....
};
#endif /* PROTOCOL_H_ */
src/tob.h
@@ -42,6 +42,7 @@
    u32 GetLevels(Message* handle , MSG* msg);
    u32 GetModuleCPU(Message* handle , MSG* pmsg);
    u16 GetModuleNum() {return mModuleNum;}
    u16 GetLevelPacketNum() {return mLevelPacketNum;}
};
#endif