コード例 #1
0
ファイル: csl_dma.c プロジェクト: Bazztord/Merruk-Technology
/* ****************************************************************************** */
static CHAL_DMA_STATUS_t dma_ucode_alloc(chal_dmac_ucode_t * ucode)
{
	UInt32 *pBuf;

	pBuf = (UInt32 *) OSDAL_ALLOCHEAPMEM(ucode->length);
	if (pBuf == NULL) {
		return CHAL_DMA_STATUS_FAILURE;
	}

	ucode->vir_addr = (UInt32) pBuf;
	ucode->phy_addr = ucode->vir_addr;
	return CHAL_DMA_STATUS_SUCCESS;
}
コード例 #2
0
// ==========================================================================
//
// Function Name: ConfigDMA
//
// Description: Configure DMA channel 
//
// =========================================================================
static Result_t ConfigDMA (
			UInt32 channel, 
			UInt8 *start, 
			UInt32 numBlocks, 
			UInt32 blockSize, 
			OSDAL_DMA_CLIENT dstClient, 
			OSDAL_DMA_DWIDTH dataWidth, 
			OSDAL_DMA_CALLBACK dmaCB)
{
	OSDAL_Dma_Data dmaData;
	OSDAL_Dma_Buffer_List *cirBufList;
	OSDAL_Dma_Chan_Info chanInfo;
	UInt32 i=0;
	UInt8	*currPos=NULL;
	UInt8	*dstAddr=NULL;

	// Configure DMA channel
    //chanInfo.chanNumber = channel;
    //chanInfo.prot = 0;
    //chanInfo.srcID = OSDAL_DMA_CLIENT_MEMORY;
    //chanInfo.dstID = dstClient;
    chanInfo.type = OSDAL_DMA_FCTRL_MEM_TO_PERI;//_CTRL_PERI;   // need to double check.
    chanInfo.srcBstSize = OSDAL_DMA_BURST_SIZE_64; // audio fifo spec
    chanInfo.dstBstSize = OSDAL_DMA_BURST_SIZE_64;
	chanInfo.srcDataWidth = dataWidth;
	chanInfo.dstDataWidth = dataWidth;
	chanInfo.incMode = OSDAL_DMA_INC_MODE_SRC; // mode_src
    chanInfo.xferCompleteCb = dmaCB;
    chanInfo.freeChan = FALSE;
    chanInfo.bCircular = TRUE;

    if(OSDAL_DMA_Config_Channel(channel, &chanInfo) != OSDAL_ERR_OK)
    {
        Log_DebugPrintf(LOGID_SOC_AUDIO,  "ConfigDMA:: Error, Configure channel failed.\n");
        return RESULT_ERROR;
    }


	switch (dstClient)
	{
		case OSDAL_DMA_CLIENT_AUDIO_OUT_FIFO:
			dstAddr = (UInt8 *) chal_audioaopath_getAFIFO_addr( NULL );
			break;
		
		case OSDAL_DMA_CLIENT_POLYRING_OUT_FIFO:
			dstAddr = (UInt8 *) chal_audiopopath_getPFIFO_addr( NULL );
			break;

		default:
			Log_DebugPrintf(LOGID_SOC_AUDIO,  "ConfigDMA:: Error, Wrong destination client, dstClient = 0x%x.\n", dstClient);
			break;
		
	}

	cirBufList = (OSDAL_Dma_Buffer_List *)OSDAL_ALLOCHEAPMEM(numBlocks * sizeof(OSDAL_Dma_Buffer_List));

	currPos = start;
	for (i = 0; i < numBlocks; i++)
	{
		cirBufList[i].buffers[0].srcAddr = (UInt32)currPos;
		cirBufList[i].buffers[0].destAddr = (UInt32)dstAddr;
		cirBufList[i].buffers[0].length = blockSize;
		cirBufList[i].buffers[0].bRepeat = 0;
		cirBufList[i].buffers[0].interrupt = 1;

		currPos += blockSize;
	}

	
	dmaData.numBuffer = numBlocks;
    dmaData.pBufList = (OSDAL_Dma_Buffer_List *)cirBufList;  
    if(OSDAL_DMA_Bind_Data(channel, &dmaData) != OSDAL_ERR_OK)
    {
        Log_DebugPrintf(LOGID_SOC_AUDIO,  "ConfigDMA:: Error, Add buffer failed.\n");
        return RESULT_ERROR;
    }

	OSDAL_FREEHEAPMEM (cirBufList);

	return RESULT_OK;
}
コード例 #3
0
static Result_t AUDIO_DRIVER_ProcessCaptureVoiceCmd(AUDIO_DDRIVER_t* aud_drv,
                                          AUDIO_DRIVER_CTRL_t ctrl_cmd,
                                          void* pCtrlStruct)
{
    Result_t result_code = RESULT_ERROR;

    Log_DebugPrintf(LOGID_AUDIO,"AUDIO_DRIVER_ProcessCaptureVoiceCmd::%d \n",ctrl_cmd );

    switch (ctrl_cmd)
    {
        case AUDIO_DRIVER_START:
            {
                UInt32 block_size;
                UInt32 frame_size;
                UInt32 num_frames;
                UInt32 left_over;
                UInt32 speech_mode = VOCAPTURE_SPEECH_MODE_LINEAR_PCM_8K;
		Boolean procEnable = FALSE;
                //check if callback is already set or not
                if( (aud_drv->pCallback == NULL) ||
                    (aud_drv->interrupt_period == 0) ||
                    (aud_drv->sample_rate == 0) ||
                    (aud_drv->num_channel == 0) ||
                    (aud_drv->bits_per_sample == 0) ||
                    (aud_drv->ring_buffer == NULL) ||
                    (aud_drv->ring_buffer_size == 0)
                    )

                {
                    Log_DebugPrintf(LOGID_AUDIO,"AUDIO_DRIVER_ProcessCaptureCmd::All Configuration is not set yet  \n"  );
                    return result_code;
                }

                //set the callback
                dspif_VPU_record_set_cb (AUDIO_DRIVER_CaptureVoiceCallback);
                
                dspframeCount= 0;
                
                /* **CAUTION: Check if we need to hardcode number of frames and handle the interrupt period seperately
                /* Block size = interrupt_period
                 * Number of frames/block = interrupt_period / 320 (20ms worth of 8khz data)
                 *
                 */

                frame_size = (aud_drv->sample_rate/1000) * 20 * 2; 
                
                block_size = aud_drv->interrupt_period;
			    num_frames = (block_size/frame_size);

                aud_drv->tmp_buffer = (UInt8*) OSDAL_ALLOCHEAPMEM(block_size);

                left_over = block_size % frame_size;

                if(left_over)
                {
                    Log_DebugPrintf(LOGID_AUDIO,"Period is not multiple of 20ms-%d  \n",left_over);
                    num_frames++;  // increase frame count by 1 more so that we have all data when we signal
                }
                if(aud_drv->sample_rate == 16000)
                    speech_mode = VOCAPTURE_SPEECH_MODE_LINEAR_PCM_16K;

                // update num_frames and frame_size
                aud_drv->num_frames = num_frames;
                aud_drv->frame_size = frame_size;
                aud_drv->speech_mode = speech_mode;

#ifdef ACTIVATE_VP_NS_FOR_GVS
				if (AUDDRV_GetAudioApp() == AUDIO_APP_RECORDING_GVS)
					procEnable = TRUE;
#endif

                result_code = dspif_VPU_record_start ( VOCAPTURE_RECORD_BOTH,
								aud_drv->sample_rate,
								speech_mode, 
								0, // used by AMRNB and AMRWB
								procEnable,
								0,
								num_frames);

            }
            break;
        case AUDIO_DRIVER_STOP:
            {
                //stop capture

                result_code = dspif_VPU_record_stop ();
                dspframeCount = 0;
            }
            break;
        case AUDIO_DRIVER_PAUSE:
            {
                //pause capture
                result_code = dspif_VPU_record_pause ();
            }
            break;
        case AUDIO_DRIVER_RESUME:
            {
                //resume capture
                result_code = dspif_VPU_record_resume ();
            }
            break;
        default:
            Log_DebugPrintf(LOGID_AUDIO,"AUDIO_DRIVER_ProcessCaptureVoiceCmd::Unsupported command  \n"  );
            break;
    }

    return result_code;
}
コード例 #4
0
//============================================================================
//
// Function Name: AUDIO_DRIVER_Open
//
// Description:   This function is used to open the audio data driver
//
//============================================================================
AUDIO_DRIVER_HANDLE_t  AUDIO_DRIVER_Open(AUDIO_DRIVER_TYPE_t drv_type)
{
    AUDIO_DDRIVER_t*  aud_drv = NULL;
    Log_DebugPrintf(LOGID_AUDIO,"AUDIO_DRIVER_Open::  \n"  );

    // allocate memory
    aud_drv = (AUDIO_DDRIVER_t*) OSDAL_ALLOCHEAPMEM(sizeof(AUDIO_DDRIVER_t));
    aud_drv->drv_type = drv_type;
    aud_drv->pCallback = NULL;
    aud_drv->interrupt_period = 0;
    aud_drv->sample_rate = 0;
    aud_drv->num_channel = AUDIO_CHANNEL_NUM_NONE;
    aud_drv->bits_per_sample = 0;
    aud_drv->ring_buffer = NULL;
    aud_drv->ring_buffer_size = 0;
    aud_drv->stream_id = 0;
    aud_drv->read_index = 0;
    aud_drv->write_index = 0;
    aud_drv->num_frames = 0;
    aud_drv->frame_size = 0;
    aud_drv->speech_mode = 0;
    aud_drv->tmp_buffer = NULL;
    aud_drv->i2s_handle = NULL;
    aud_drv->pVoipULCallback = NULL;
    aud_drv->pVoipDLCallback = NULL;

    switch (drv_type)
    {
        case AUDIO_DRIVER_PLAY_VOICE:
        case AUDIO_DRIVER_PLAY_AUDIO:
        case AUDIO_DRIVER_PLAY_RINGER:
            {
                // initialize audvoc render
                //aud_drv->stream_id = csl_audio_render_init (CSL_AUDVOC_DEV_NONE,CSL_AUDVOC_DEV_RENDER_POLYRINGER);
                audio_render_driver =  aud_drv;
            }
            break;
        case AUDIO_DRIVER_CAPT_HQ:
            {
                //aud_drv->stream_id = csl_audio_capture_init (CSL_AUDVOC_DEV_CAPTURE_AUDIO,CSL_AUDVOC_DEV_NONE);
                audio_capture_driver = aud_drv;
            }
            break;
        case AUDIO_DRIVER_CAPT_VOICE:
            {
                dspif_VPU_record_init ();
                audio_capture_driver = aud_drv;
            }
            break;

        case AUDIO_DRIVER_CAPT_FM:
            {
                aud_drv->i2s_handle = I2SDRV_Get_handle(I2S_BLK1_ID);
                Log_DebugPrintf(LOGID_AUDIO, "call I2SDRV_Get_handle. = %x\n", aud_drv->i2s_handle);
                audio_capture_driver = aud_drv;
            }
            break;

        case AUDIO_DRIVER_VOIP:
            {
                audio_voip_driver = aud_drv;
            }
            break;
        default:
            Log_DebugPrintf(LOGID_AUDIO,"AUDIO_DRIVER_Open::Unsupported driver  \n"  );
            break;
    }
    return ((AUDIO_DRIVER_HANDLE_t)aud_drv);
}
コード例 #5
0
// ==========================================================================
//
// Function Name: ConfigDMA
//
// Description: Configure DMA channel 
//
// =========================================================================
static Result_t ConfigDMA(
			UInt32 channel, 
			UInt8 *start, 
			UInt32 numBlocks, 
			UInt32 blockSize, 
			OSDAL_DMA_CLIENT srcClient,
			OSDAL_DMA_DWIDTH dataWidth,
			OSDAL_DMA_CALLBACK dmaCB)
{
	OSDAL_Dma_Data dmaData;
	OSDAL_Dma_Buffer_List *cirBufList;
	OSDAL_Dma_Chan_Info chanInfo;
	UInt32 i=0;
	UInt8	*currPos = 0;
	UInt8	*srcAddr = 0;

    Log_DebugPrintf(LOGID_AUDIO, "ConfigDMA:: channel: 0x%x, numBlocks = 0x%x, blockSize = 0x%x\n", channel, numBlocks, blockSize);

	// Configure DMA channel
    //chanInfo.chanNumber = channel;
    //chanInfo.prot = 0;
    //chanInfo.srcID = srcClient;
    //chanInfo.dstID = DMA_CLIENT_MEMORY;
    chanInfo.type = OSDAL_DMA_FCTRL_PERI_TO_MEM;
/* [email protected] 2012.07.03 begin */
//DMA issue:obtain semaphore timeout  
//CSP#523614  
    chanInfo.srcBstSize = OSDAL_DMA_BURST_SIZE_16; // audio fifo spec
    chanInfo.dstBstSize = OSDAL_DMA_BURST_SIZE_16;
/* [email protected] 2012.07.03 end */
    chanInfo.srcDataWidth = dataWidth;
    chanInfo.dstDataWidth = dataWidth;
    chanInfo.srcMaster = 0;
    chanInfo.dstMaster = 0;
    chanInfo.incMode = OSDAL_DMA_INC_MODE_DST; // mode_dst
    chanInfo.xferCompleteCb = dmaCB;
    chanInfo.freeChan = FALSE;
    chanInfo.bCircular = TRUE;
   
    if(OSDAL_DMA_Config_Channel(channel, &chanInfo) != OSDAL_ERR_OK)
    {
        Log_DebugPrintf(LOGID_AUDIO, "ConfigDMA:: Error, Configure channel failed.\n");
        return RESULT_ERROR;
    }


	switch (srcClient)
	{
		case OSDAL_DMA_CLIENT_AUDIO_IN_FIFO:
			srcAddr = (UInt8 *) chal_audioaipath_getAFIFO_addr( NULL );
			break;
		
		case OSDAL_DMA_CLIENT_AUDIO_WB_MIXERTAP:
			srcAddr = (UInt8 *) chal_audiomixertap_getAFIFO_addr( NULL );
			break;

		default:
			Log_DebugPrintf(LOGID_AUDIO, "ConfigDMA:: Error, Wrong source client, srcClient = 0x%x.\n", srcClient);
			break;
		
	}

	cirBufList = (OSDAL_Dma_Buffer_List *)OSDAL_ALLOCHEAPMEM(numBlocks * sizeof(OSDAL_Dma_Buffer_List));

	currPos = start;
	for (i = 0; i < numBlocks; i++)
	{
		cirBufList[i].buffers[0].srcAddr = (UInt32)srcAddr;
		cirBufList[i].buffers[0].destAddr = (UInt32)currPos;
		cirBufList[i].buffers[0].length = blockSize;
		cirBufList[i].buffers[0].bRepeat = 0;
		cirBufList[i].buffers[0].interrupt = 1;

		currPos += blockSize;
	}

	dmaData.numBuffer = numBlocks;
    dmaData.pBufList = (OSDAL_Dma_Buffer_List *)cirBufList;  
    if(OSDAL_DMA_Bind_Data(channel, &dmaData) != OSDAL_ERR_OK)
    {
        Log_DebugPrintf(LOGID_AUDIO, "ConfigDMA:: Error, Add buffer failed.\n");
        return RESULT_ERROR;
    }

	OSDAL_FREEHEAPMEM (cirBufList);

	return RESULT_OK;
}