/* * scene.cpp * * Created on: 2025Äê7ÔÂ21ÈÕ * Author: 86189 */ #include #include #include #include "config.h" #include "ModuleExport.h" #include "f2f.h" #include "scene.h" #include "protocol_internal.h" #include "moduleexport.h" #include "crc.h" #include "../drv/memory.h" s32 Scene::str_delim(const s8* str, u16 logic_channel[]) { s8 pstr[32]; s8 * ptr; s32 i = 0; strcpy(pstr, str); ptr = strtok(pstr, "|"); if (strcmp(ptr, str) == 0) { s8 start, end; ptr = strtok(pstr, "-"); start = atoi(ptr); ptr = strtok(NULL, "-"); end = atoi(ptr); if(start==end) return 0; while (start <= end) { logic_channel[i++] = start++; } return i; } else { while (ptr) { logic_channel[i++] = atoi(ptr); ptr = strtok(NULL, "|"); } return i; } } void *Scene::get_param(s32 proc_id) { for (auto& proc : proc_list) { if (proc.proc_id == proc_id) { // printf("proc:%d,addr:0x%x\n", proc_id, proc.parameters); return proc.parameters; } } return nullptr; } s32 Scene::convert_to_bin(u8* bin) { s32 i ,j; struct FlowChartHead* flowchart = (struct FlowChartHead*)bin; u32 size = sizeof(struct FlowChartHead); s32 ninports,noutports; 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); dbg_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 == ModuleType::PROC_NONE){ continue; } //ducker & spl with mix. if(p->proc_type == PROC_DUCKER || p->proc_type == PROC_CONTINUNOUS_SPL) { ninports = str_delim(proc_list[1].inportstr, &rxBufID[1]) + 1; // rxBufID[0] is the dataIn Frame, rxBufID[1]~rxBufID[inportstr] is the mix channel. } 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[dsp_index]) { dsp_input_num[dsp_index] = rxBufID[j]; } } for(j = 0 ; j< noutports ;j ++) { if(txBufID[j] > dsp_output_num[dsp_index]) { dsp_output_num[dsp_index] = txBufID[j]; } } 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(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); // dbg_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); } } //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->compress = 0; flowchart->version = 1; flowchart->crc = 0; crc = CRC::crc32((const u8*)bin, size); flowchart->crc = crc; return size; }