📄 wm97audiopaths.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: WM97AudioPaths.c 2364 2005-11-04 15:56:03Z ib $
*
* This file contains definitions and routines for controlling audio paths.
*
* NOTE: This code is here as an example. Each application is different
* and the input paths require will vary. You should optimise these functions
* for your particular application.
*
* 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 "WMAudio.h"
#include "WM97AudioPaths.h"
/*
* Global definitions
*/
/*
* Only build this if we are asked to.
*/
#if WM_AUDIO && WM_AC97
/*
* Function prototypes
*/
/*-----------------------------------------------------------------------------
* Function: WM97SetLineInRecPaths
*
* Set up Line In to ADC, left and/or right channels as the record path.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* lineInL signal to record on left ADC channel.
* lineInR signal to record on right ADC channel.
*
* Returns: WMSTATUS
* See WMStatus.h
*---------------------------------------------------------------------------*/
WMSTATUS WM97SetLineInRecPaths( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL lineInL,
WM_AUDIO_SIGNAL lineInR
)
{
WMSTATUS status;
/* Make sure active signals are Line In */
WM_ASSERT( hDevice,
( ( WM_SIGNAL_IS_LINEIN( lineInL ) || WM_AUDIO_IGNORE == lineInL ) &&
( WM_SIGNAL_IS_LINEIN( lineInR ) || WM_AUDIO_IGNORE == lineInR ) &&
( WM_AUDIO_IGNORE != lineInL || WM_AUDIO_IGNORE != lineInR ) )
);
/* Set the ADC to 0dB */
status = WMAudioSetSignalVolumeDb( hDevice,
WM_AUDIO_HIFI_ADC,
0,
WM_CHANNEL_ALL
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetLineInRecPath - Setting ADC gain failed: %s",
WMStatusText( status ) ) );
goto exit;
}
/* Set line in to 0dB */
if ( WM_AUDIO_IGNORE != lineInL )
{
status = WMAudioSetSignalVolumeDb( hDevice,
lineInL,
0,
WM_CHANNEL_ALL
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetMicRecPaths - Setting left line volume failed: %s",
WMStatusText( status ) ) );
goto exit;
}
}
if ( WM_AUDIO_IGNORE != lineInR && lineInL != lineInR )
{
status = WMAudioSetSignalVolumeDb( hDevice,
lineInR,
0,
WM_CHANNEL_ALL
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetMicRecPaths - Setting right line volume failed: %s",
WMStatusText( status ) ) );
goto exit;
}
}
/* Set Record Source to Line In for selected channels */
status = WMAudioSetRecordSources( hDevice, lineInL, lineInR );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetLineInRecPath - Setting record source failed: %s",
WMStatusText( status ) ) );
goto exit;
}
/* Take the ADC input from before the DAC output is added */
if ( IS_WM9705_FAMILY( hDevice ) )
{
status = WMSetField( hDevice,
WM97_ADD_FUN_CONTROL,
WM9705_ADDFUN_ADCNDAC,
WM9705_ADDFUN_ADCNDAC
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WMAudioSetLineInRecPath - Removing DAC output from ADC input failed: %s",
WMStatusText( status ) ) );
goto exit;
}
}
/* Enable sidetone volume to zero dB */
if ( IS_WM9712_FAMILY( hDevice ) )
{
status = WMSetField( hDevice,
WM97_SIDETONE_VOLUME,
WM9712_SIDETONE_ALC_0DB,
WM9712_SIDETONE_MIC_MUTE | WM9712_SIDETONE_ALC_MUTE_MASK
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetLineInRecPath - Enabling sidetone failed: %s",
WMStatusText( status ) ) );
goto exit;
}
}
exit:
return status;
}
/*-----------------------------------------------------------------------------
* Function: WM97SetMicRecPaths
*
* Set up a microphone path to ADC left and/or right channels as the
* record path.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* micSignalL left channel microphone input to use.
* micSignalR Right channelmicrophone input to use.
* channels which ADC channel(s) to record signal on.
*
* Returns: WMSTATUS
* See WMStatus.h
*---------------------------------------------------------------------------*/
WMSTATUS WM97SetMicRecPaths( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL micSignalL,
WM_AUDIO_SIGNAL micSignalR
)
{
WMSTATUS status;
/* Set the ADC to 0dB */
/* Make sure active signals are Mic */
WM_ASSERT( hDevice,
( ( WM_SIGNAL_IS_MIC( micSignalL ) || WM_AUDIO_IGNORE == micSignalL ) &&
( WM_SIGNAL_IS_MIC( micSignalR ) || WM_AUDIO_IGNORE == micSignalR ) &&
( WM_AUDIO_IGNORE != micSignalL || WM_AUDIO_IGNORE != micSignalR ) )
);
/* Set the ADC to 0dB */
status = WMAudioSetSignalVolumeDb( hDevice,
WM_AUDIO_HIFI_ADC,
0,
WM_CHANNEL_ALL
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetMicRecPaths - Setting ADC gain failed: %s",
WMStatusText( status ) ) );
goto exit;
}
/* Set Mic to Mixers at 0dB */
if ( WM_AUDIO_IGNORE != micSignalL )
{
status = WMAudioSetSignalVolumeDb( hDevice,
micSignalL,
0,
WM_CHANNEL_ALL
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetMicRecPaths - Setting left MIC volume failed: %s",
WMStatusText( status ) ) );
goto exit;
}
}
if ( WM_AUDIO_IGNORE != micSignalR && micSignalL != micSignalR )
{
status = WMAudioSetSignalVolumeDb( hDevice,
micSignalR,
0,
WM_CHANNEL_ALL
);
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetMicRecPaths - Setting right MIC volume failed: %s",
WMStatusText( status ) ) );
goto exit;
}
}
status = WMAudioSetRecordSources( hDevice, micSignalL, micSignalR );
if ( WM_ERROR( status ) )
{
WM_TRACE( hDevice,
( "WM97SetMicRecPaths -Setting record source failed: %s",
WMStatusText( status ) ) );
goto exit;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -