am_hw_primitive_builder_interrupt.cc

来自「Motorola synergy audio component」· CC 代码 · 共 881 行 · 第 1/3 页

CC
881
字号
    *(seem_bank_wr_ptr[current_SEEM_bank]) += (DSP_MCU_VA_RECORD_DATA_WORD_LEN + 2) * AM_MCOUNT_VA;#if (AUDIO_CDMA == TRUE)      ReadConfirmed();#endif    //if eom message set, release banks, reset pointers    //and abandon any attempts to transfer data    if( am_va_vr_int_info.eom == TRUE )        {        //switch to other buffer        Switch_Banks(current_SEEM_bank);        *(seem_bank_wr_ptr[current_SEEM_bank]) = start_seem_bank_ptr[current_SEEM_bank];        suReleaseSem( sem_seem_data_stream_bank_a_free ,&GINT_SU_Status);        suReleaseSem( sem_seem_data_stream_bank_b_free ,&GINT_SU_Status);        }    }/* DESCRIPTION:       if we are out of data, tell seem that we are finished and       send the playback off to the DSP.    INPUTS:       none   OUTPUTS:       none   IMPORTANT NOTES:       none*/void FinishTransfer(){            SU_RET_STATUS GINT_SU_Status;     //reset bank     current_SEEM_bank = BANK_A;     //reset read pointers     *(seem_bank_rd_ptr[BANK_A]) = start_seem_bank_ptr[BANK_A];     *(seem_bank_rd_ptr[BANK_B]) = start_seem_bank_ptr[BANK_B];     //release both banks     suReleaseSem( sem_seem_data_stream_bank_a_free, &GINT_SU_Status );     suReleaseSem( sem_seem_data_stream_bank_b_free, &GINT_SU_Status );     //send primitive to DSP indicating that data transfer is done     //only if last transfer was of MCU_DSP_VA_PLAYBACK type     if( am_va_vr_int_info.data_type == AM_MCU_DSP_VA_PLAYBACK_DATA )     {          UINT16 buffer[] = { MCU_DSP_VA_PLAYBACK_OFF,                      (UINT16)MCU_DSP_VA_PLAYBACK_OFF_WORD_LEN,                      (UINT16)!(am_va_vr_int_info.eom == TRUE) };        /* Don't send the MCU_DSP_VA_PLAYBACK_OFF if we          * have already sent a stop before (or)         * if a MCU_DSP_VA_PLAYBACK_ON wasn't sent.         */        if (am_va_vr_int_info.is_va_playback_active == TRUE)        {            HAPI_MDI_QUEUE_write(                 MCU_DSP_AUDIO_COMMAND,                 buffer,                 AM_HW_MSG_HEADER_WORD_LEN + MCU_DSP_VA_PLAYBACK_OFF_WORD_LEN,                TRUE );            /*Datalog the MDI data */            am_send_log_data(                 AUD_MDI_Q_WRITE_VA_VR,                 (char *)buffer,                 (AM_HW_MSG_HEADER_WORD_LEN + MCU_DSP_VA_PLAYBACK_OFF_WORD_LEN) * 2);            am_va_vr_int_info.is_va_playback_active = FALSE;            am_va_vr_int_info.data_mode = SEEM_FDI_NO_TRANSFER;        }        //this function does not have access to the state variables of the AM        //notify the AM to change its state on the playback off complete (VR only)        AM_Relay_Layer::set_handle_next_vtag_complete();    }}/* DESCRIPTION:       During playback check the other bank to see if we have data       if no data exists stop the playback.  However, if we have data       ready to go to the DSP, don't send the stop playback until       after we have processed the frams to the dsp.           INPUTS:       none   OUTPUTS:       none    IMPORTANT NOTES:       none*/UINT16 CheckOtherBank(BOOL DataExists){   SU_RET_STATUS GINT_SU_Status;   UINT16 num_words;   //reset read pointer in current bank   *(seem_bank_rd_ptr[current_SEEM_bank]) = start_seem_bank_ptr[current_SEEM_bank];   *(seem_bank_wr_ptr[current_SEEM_bank]) = start_seem_bank_ptr[current_SEEM_bank];   //switch to other bank   Switch_Banks(current_SEEM_bank);   //reset read pointer in current bank   *(seem_bank_rd_ptr[current_SEEM_bank]) = start_seem_bank_ptr[current_SEEM_bank];   //release previous bank   suReleaseSem(( current_SEEM_bank == BANK_A ) ? sem_seem_data_stream_bank_b_free :                                                  sem_seem_data_stream_bank_a_free ,&GINT_SU_Status );   //check if any data in new buffer   num_words = *(seem_bank_wr_ptr[current_SEEM_bank]) - *(seem_bank_rd_ptr[current_SEEM_bank]);    if( num_words == 0 && !DataExists) //if still no data       {           FinishTransfer();       }   return num_words;}/* DESCRIPTION:       Transfers data from the SEEM to the MDI buffer buffer during       VA/VR operations    INPUTS:       none   OUTPUTS:       none   IMPORTANT NOTES:       none*/void TransferVAFromSeemToMDI()    {       UINT16 words_transferred = 0;    UINT16 num_words;    UINT16 cnt = 0;    BOOL done = FALSE;    UINT16 tmpbuff[AM_MCOUNT_VA * (MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + 2) ];    UINT16 *tmpptr = tmpbuff;     UINT16 blank_data[] = {0,0,0,0,0,0};  //silence data for DSP to complete messages        for (cnt = 0; cnt < AM_MCOUNT_VA; cnt ++)    {        num_words = *(seem_bank_wr_ptr[current_SEEM_bank]) -  *(seem_bank_rd_ptr[current_SEEM_bank]);        //if no data in current buffer, switch to other buffer        if( num_words < (MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + 2)  )        {            // check to see if data exists in the other bank,            // if it doesn't if we have frams to process then            // make sure that you call L1_MODEM_write with the            // frames sitting in the temporary buffer            if((num_words = CheckOtherBank(cnt != 0)) == 0)             {                if(cnt != 0)                {                     //In this case, there is no data left in seem, but we still need to send 4                    //messages to DSP (loop through AM_MCOUNT_VA isn't complete).                      //We'll fill tmpbuff with the correct header for each message                    //but add 0's as the data so the DSP plays silence.                    for(;cnt<AM_MCOUNT_VA;cnt++)                    {                                                *tmpptr = MCU_DSP_VA_PLAYBACK_DATA;                        *(tmpptr+1) = MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN;                        memcpy(tmpptr+2, blank_data, MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN * 2);                        tmpptr += MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + 2;                    }                    break;                }                else                {                    return;                }            }        }                *(seem_bank_rd_ptr[current_SEEM_bank]) += 2;                *tmpptr =  MCU_DSP_VA_PLAYBACK_DATA;        *(tmpptr+1) = MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN;        memcpy(tmpptr+2, *(seem_bank_rd_ptr[current_SEEM_bank]), MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN * 2);        tmpptr += MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + 2;        *(seem_bank_rd_ptr[current_SEEM_bank])+= MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN;        am_va_vr_int_info.msg_offset += MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN * 2;    }    HAPI_MDI_QUEUE_write(MCU_DSP_AUDIO_DATA, tmpbuff,  (MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + 2)* AM_MCOUNT_VA, TRUE);    /*Datalog the MDI data */    am_send_log_data(AUD_MDI_Q_WRITE_VA_VR, (char *)tmpbuff, (MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + 2)* AM_MCOUNT_VA * 2);}#if ((AUDIO_GSM == TRUE) || (AUDIO_TDMA == TRUE))/* DESCRIPTION:       Handles VA/VR data transfer in response to the        RX/TX0 interrupt from the DSP.     INPUTS:       none   OUTPUTS:       none   IMPORTANT NOTES:       This function must be of "void" type and should not accept any parameters.       This will allow for the function to be called from "C" code.*/void AUDIO_VA_VR_transfer_data( void ){GINT_interrupt();}#endif  /* GSM Signaling or TDMA Signaling *//* DESCRIPTION:       Transfers data from the RAM buffer described by the VST structure parameters       audVstParams.audio_data_size and audVstParams.audio_data_address to the MDI        buffer buffer through the GINT ISR.   INPUTS:       none   OUTPUTS:       none   IMPORTANT NOTES:       none*/void TransferVAFromRAMToMDI(void){    UINT16 cnt = 0;    BOOL done = FALSE;    UINT16 tmpbuff[AM_MCOUNT_VA * (MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + AM_HW_MSG_HEADER_WORD_LEN) ];    UINT16 *tmpptr = tmpbuff;    for (cnt = 0; cnt < AM_MCOUNT_VA; cnt ++)    {        //if no more data in the audVstParams buffer, return from the routine        if( am_va_vr_int_info.msg_offset >= audVstParams.audio_data_size )        {            /* Don't send the MCU_DSP_VA_PLAYBACK_OFF if we have already sent a stop before (or)             * if a MCU_DSP_VA_PLAYBACK_ON wasn't sent.             */            if (am_va_vr_int_info.is_va_playback_active == TRUE)            {                //send primitive to DSP indicating that data transfer is done                //only if last transfer was of MCU_DSP_VA_PLAYBACK type                UINT16 buffer[] = { MCU_DSP_VA_PLAYBACK_OFF,                                    (UINT16)MCU_DSP_VA_PLAYBACK_OFF_WORD_LEN,                                    (UINT16)!(am_va_vr_int_info.eom == TRUE) };                //write buffer to the API                HAPI_MDI_QUEUE_write(MCU_DSP_AUDIO_COMMAND,                                     buffer,                                     AM_HW_MSG_HEADER_WORD_LEN + MCU_DSP_VA_PLAYBACK_OFF_WORD_LEN,                                     TRUE);                /*Datalog the MDI data */                am_send_log_data(AUD_MDI_Q_WRITE_VA_VR,                                 (char *)buffer,                                 (AM_HW_MSG_HEADER_WORD_LEN + MCU_DSP_VA_PLAYBACK_OFF_WORD_LEN) * 2);                                am_va_vr_int_info.is_va_playback_active = FALSE;                am_va_vr_int_info.data_mode = SEEM_FDI_NO_TRANSFER;                return;                            }        }        *tmpptr =  MCU_DSP_VA_PLAYBACK_DATA;        *(tmpptr+1) = MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN;        memcpy(tmpptr+2, (UINT8 *)audVstParams.audio_data_address + am_va_vr_int_info.msg_offset, VST_MAX_VOCODED_DATA_FRAME_SIZE);        tmpptr += MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + AM_HW_MSG_HEADER_WORD_LEN;        am_va_vr_int_info.msg_offset += VST_MAX_VOCODED_DATA_FRAME_SIZE;    }    HAPI_MDI_QUEUE_write(MCU_DSP_AUDIO_DATA, tmpbuff,                        (MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + AM_HW_MSG_HEADER_WORD_LEN)* AM_MCOUNT_VA,                        TRUE);    /*Datalog the MDI data */    am_send_log_data(AUD_MDI_Q_WRITE_VA_VR,                     (char *)tmpbuff, 		     (MCU_DSP_VA_PLAYBACK_DATA_WORD_LEN + AM_HW_MSG_HEADER_WORD_LEN)* AM_MCOUNT_VA * 2);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?