static void myAppCreateHighRateDAL(void) { cliPrintf("high rate dal.\n\r"); if(PreviousDAL) dalUninstallCallback(myDalCallBack); //Let's build our audio configuration with "dal", We want to allow all rates above 96KHz dalCreateInterface(eDAL_INTERFACE_1, eDAL_RATE_MODE_HIGH, MY_INPUT_DEVICES_HIGH, MY_OUTPUT_DEVICES_HIGH); //default we will run at internal rate 48KHz, the computer will change that when attached dalSetClockSource (eDAL_INTERFACE_1, eDAL_CLK_SRC_AVS_SYT1, eDAL_NOMINAL_RATE_192); //we need to setup our routing //let the 4 AES channels take data from the first Isoc receiver dalSetRoute(eDAL_INTERFACE_1, TX_AES_CH0_3, RX_AVS1_CH0_3); //let the first 8 Isoc 1 transmitter channels take data from the 8 AES channels dalSetRoute(eDAL_INTERFACE_1, TX_AVS1_CH0_3, RX_AES_CH0_3); //the call back function defined above needs to be installed into "dal" dalInstallCallback(&myDalSubscribedEvents, 200, myDalCallBack, 0); //configure device for MIDI based on a function in targetBoard. For the EVAL //board this is determined by DIP SW 1 myAvcDriverTxConfigLow[0].midiChannels = 1; myAvcDriverRxConfigLow[0].midiChannels = 1; avcDriverConfigure (myAvcDriverTxConfigLow, MY_NB_TX_ISOC_STREAMS_HIGH, myAvcDriverRxConfigLow, MY_NB_RX_ISOC_STREAMS_HIGH, myAvcDriverCallBack); myAppInitializeI2S(); myAppSetI2SHigh(); // now we are ready to start the whole thing, it actually wont start until we return from // this function as threads are not enabled yet. If we want to have some code running after // this we need to create a thread. We don't need that here, our call backs will do things // for us. dalStartInterface(eDAL_INTERFACE_1); }
// This function handles the rate change request from the driver. // If the rate mode has changed it will create a new DAL. static HRESULT myAppChangeSR(DICE_DRIVER_CB_DATA * pData) { HRESULT hResult = NO_ERROR; uint32 notify = 0; DAL_RATE_MODE_ENUM driverRateMode; driverRateMode = dalRateByID(pData->rate)->rateMode; if (driverRateMode != lastDriverRatemode) { //Driver asked for a change of rate mode lastDriverRatemode = driverRateMode; myAppCreateDAL(driverRateMode); // Send the RX and TX Configuration Notification as this might // have resulted in a change of the Rx and Tx streams going // to the computer. This will for example happen if the device // has ADAT, when going from 48k to 96k ADAT will be reduced // to 4 channels (SMUXII) notify |= DD_NOTIFY_RX_CFG_CHG_BIT | DD_NOTIFY_TX_CFG_CHG_BIT; } //Change the Clock as instructed by driver, this could be a change //in clock source, nominal rate or both. dalSetClockSource (eDAL_INTERFACE_1, pData->source, pData->rate); //Send the Clock Setting Accept Notification, this should always be send notify |= DD_NOTIFY_CLOCK_ACP; diceDriverNotifyHost(notify); return hResult; }
void StandAloneInitialize (void) { //we need to figure out what dal to create EAP_STND_ALONE_CFG const * pStdaCfg; DAL_RATE_MODE_ENUM rate_mode = eDAL_RATE_MODE_LOW_MID; DAL_NOMINAL_RATE_ENUM rate = eDAL_NOMINAL_RATE_ANY; DAL_CLOCK_SOURCE_ENUM clksrc; pStdaCfg = eapGetStandaloneCfg(); clksrc = CLOCK_SOURCE[pStdaCfg->clkSrc]; if (clksrc == eDAL_CLK_SRC_AESRX0) { rate_mode = eDAL_RATE_MODE_ALL; //auto lock to 32k-192k } else { //illegal, do something rate = eDAL_NOMINAL_RATE_48; } dalCreateInterface(eDAL_INTERFACE_1, rate_mode, STDA_INPUT_DEVICES,STDA_OUTPUT_DEVICES); dalSetClockSource (eDAL_INTERFACE_1, clksrc, rate); dalStartInterface(eDAL_INTERFACE_1); //update the routing now according to the currently locked rate mode, in auto modes this might change //so in that case this function must be called. updateStdaRouting(); }
static HRESULT myAppChangeSR(AVC_DRIVER_CB_DATA * pData) { HRESULT hResult = NO_ERROR; uint32 notify = 0; cliPrintf("Change SR: old=%x, new=%x\n\r", OldRate, pData->rate); switch(pData->rate) { case eDAL_NOMINAL_RATE_32: case eDAL_NOMINAL_RATE_44_1: case eDAL_NOMINAL_RATE_48: if(OldRate > eDAL_NOMINAL_RATE_48) { cliPrintf(" low rate\n\r"); myAppCreateLowRateDAL(); //Send the RX and TX Configuration Notification notify |= DD_NOTIFY_RX_CFG_CHG_BIT | DD_NOTIFY_TX_CFG_CHG_BIT; } break; case eDAL_NOMINAL_RATE_88_2: case eDAL_NOMINAL_RATE_96: if((OldRate < eDAL_NOMINAL_RATE_88_2) || (OldRate > eDAL_NOMINAL_RATE_96)) { myAppCreateMidRateDAL(); //Send the RX and TX Configuration Notification notify |= DD_NOTIFY_RX_CFG_CHG_BIT | DD_NOTIFY_TX_CFG_CHG_BIT; } break; case eDAL_NOMINAL_RATE_176_4: case eDAL_NOMINAL_RATE_192: if(OldRate < eDAL_NOMINAL_RATE_176_4) { myAppCreateHighRateDAL(); //Send the RX and TX Configuration Notification notify |= DD_NOTIFY_RX_CFG_CHG_BIT | DD_NOTIFY_TX_CFG_CHG_BIT; } break; default: cliPrintf("No change.\n\r"); break; } OldRate = pData->rate; if(hResult == NO_ERROR) { //Change the Clock Now dalSetClockSource (eDAL_INTERFACE_1, pData->source, pData->rate); //Send the Clock Setting Accept Notification notify |= DD_NOTIFY_CLOCK_ACP; OldRate = pData->rate; } return hResult; }
HRESULT myAvcDriverCallBack (AVC_DRIVER_MSG_ENUM msg, AVC_DRIVER_CB_DATA * pData) { uint32 notify; // why did the driver call us? switch (msg) { case eAVCDR_MSG_CLOCK_CHG: // The computer has requested a change of clock and source. We // should honour that by issuing a call to "dal" //Check if DAL needs to be changed notify = myAppChangeSR(pData); //Change the Clock Now dalSetClockSource (eDAL_INTERFACE_1, pData->source, pData->rate); break; case eAVCDR_MSG_ATTACH: // The computer attached itself to this device // this typically happens after the computer boots, but also after // bus resets or the first time the driver is installed // In this application we don't care LED_ON(DRIVER_ATCH_LED_ID); break; case eAVCDR_MSG_DETACH: // The computer detached itself from this device // this typically happens when the computer shuts down // or at a bus reset. // In this application we don't care LED_OFF(DRIVER_ATCH_LED_ID); break; case eAVCDR_MSG_ENABLE: // The computer has enabled streaming LED_ON(DRIVER_EN_LED_ID); break; case eAVCDR_MSG_DISABLE: // The computer has disabled streaming LED_OFF(DRIVER_EN_LED_ID); break; } return NO_ERROR; }
static HRESULT myAppChangeSR(DICE_DRIVER_CB_DATA * pData) { HRESULT hResult = NO_ERROR; uint32 notify = 0; if (dalRateByID (pData->rate)->rateMode != lastDriverRateMode) { lastDriverRateMode = dalRateByID (pData->rate)->rateMode; dalCreateInterface(eDAL_INTERFACE_1, lastDriverRateMode, INPUT_DEVICES,OUTPUT_DEVICES); eapDriverChangeRateMode (lastDriverRateMode); dalStartInterface(eDAL_INTERFACE_1); //Send the RX and TX Configuration Notification notify |= DD_NOTIFY_RX_CFG_CHG_BIT | DD_NOTIFY_TX_CFG_CHG_BIT; } //Change the Clock Now dalSetClockSource (eDAL_INTERFACE_1, pData->source, pData->rate); //Send the Clock Setting Accept Notification notify |= DD_NOTIFY_CLOCK_ACP; diceDriverNotifyHost(notify); return hResult; }