⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmi2saudio.c

📁 WM9713 audio codec driver for WinCE 5.0
💻 C
字号:
/*-----------------------------------------------------------------------------
 * Copyright (c) Wolfson Microelectronics plc.  All rights reserved.
 *
 * This software as well as any related documentation is furnished under 
 * license and may only be used or copied in accordance with the terms of the 
 * license. The information in this file is furnished for informational use 
 * only, is subject to change without notice, and should not be construed as 
 * a commitment by Wolfson Microelectronics plc. Wolfson Microelectronics plc
 * assumes no responsibility or liability for any errors or inaccuracies that
 * may appear in this document or any software that may be provided in
 * association with this document. 
 *
 * Except as permitted by such license, no part of this document may be 
 * reproduced, stored in a retrieval system, or transmitted in any form or by 
 * any means without the express written consent of Wolfson Microelectronics plc. 
 *
 * $Id: WMI2SAudio.c 2335 2005-10-21 09:07:06Z ib $
 *
 * This file contains platform-independent routines for controlling the audio
 * operation on Wolfson codecs.
 *
 * Warning:
 *  This driver is specifically written for Wolfson Codecs. It is not a 
 *  general CODEC device driver.
 *
 * -----------------------------------------------------------------------------*/

/*
 * Include files
 */
#include "WMCommon.h"
#include "WMDevice.h"
#include "WMControlLink.h"
#include "WMPlatformI2S.h"
#include "WMPlatformSSP.h"
#include "WMPlatformDebug.h"
#include "WMGlobals.h"
#include "WMI2SAudio.h"
#include "WMTestCommon.h"
#include "WMInternalTests.h"

/*
 * Only build this if we're doing Audio support for WMI2S devices.
 */
#if WM_AUDIO && WM_I2S

#ifndef WM_MCLK_FREQUENCY
    /*
     * We need to know our MCLK frequency.  This should be a value in Hz
     * such as 12000000 (for 12MHz).
     */
#   error Please define WM_MCLK_FREQUENCY (in Hz) in WMPlatformConfig.h
#endif

/*
 * Global definitions
 */

/*
 * A macro which works out whether the voice interface is enabled.
 */
#if WM_VOICE
#   define IS_VOICE_ENABLED( _pCtx )    \
        (_pCtx->v_pWMData->audioData.flags & WM_AUDIO_VOICE_CONFIGURED)
#else
#   define IS_VOICE_ENABLED( _pCtx )    FALSE
#endif

/*
 * A macro which works out which interface to use.
 * For HiFi playback it's HiFi.  For Voice anything it's voice.  For HiFi
 * record it's HiFi if there is no voice, otherwise it's Voice.
 */
#define STREAM_USES_HIFI( _stream, _pCtx )                                      \
    ( ( WM_STREAM_HIFI_OUT == _stream ) ||                                      \
      ( WM_STREAM_HIFI_IN == _stream && !( IS_VOICE_ENABLED(_pCtx) ) )          \
    )

/*
 * Function prototypes
 */

/*-----------------------------------------------------------------------------
 * Function:    WMI2SSetSampleRate
 *
 * Called to set the sample rate in the audio-specific sections of the chip. 
 *
 * Parameters:
 *      hDevice      handle to the device (from WMOpenDevice)
 *      stream       The stream for which to set the sample rate
 *      sampleRate   The requested sample rate.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h.
 *---------------------------------------------------------------------------*/
WMSTATUS WMI2SSetSampleRate( WM_DEVICE_HANDLE hDevice,
                             WM_STREAM_ID     stream, 
                             WM_SAMPLE_RATE   sampleRate
                           )
{
	WM_DEVICE_CONTEXT       *pDeviceContext = WMHANDLE_TO_DEVICE( hDevice );
	WMSTATUS                status;
	WM_BOOL                 isHiFi;
	WM_BOOL                 isMaster;

	isHiFi = STREAM_USES_HIFI( stream, pDeviceContext );
    
	if ( isHiFi )
	{
		isMaster = pDeviceContext->v_pWMData->audioData.flags & WM_AUDIO_HIFI_MASTER;
	}
	else
	{
		WM_ASSERT( hDevice, FALSE );
	}
 
	if ( isMaster )
	{    
		/* We do not have device control at this point
		 * so we should just pass though.
		 */
		WM_ASSERT( hDevice, FALSE );
	}
	else    /* => slave */
	{
		/*
		 * Now set up the platform.
		 */
		if ( WM_IS_HIFI_STREAM( stream ) )
		{
			/*
			 * Set the I2S sample rate.
			 */
			status = WMPlatformI2SSetSampleRate( hDevice, sampleRate );
			if ( WM_ERROR( status ) )
			{
			    goto error;
			}
		}
	}

	/*
	 * We're done.
	 */
	return WMS_SUCCESS;
    
error:
	return status;
}

#endif  /* WM_AUDIO && WM_I2S */

/*------------------------------ END OF FILE ---------------------------------*/

⌨️ 快捷键说明

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