📄 wm8753audiopaths.c
字号:
WM8753_LEFTADCSEL_LINE1,
WM8753_RIGHTADCSEL_MASK |
WM8753_LEFTADCSEL_MASK
);
if( WM_ERROR( status ) )
{
goto error;
}
/*
* Enable LM Signal to Left Mixer.
*/
status = WMSetField( hDevice,
WM8753_LEFT_OUT_MIX_1,
WM8753_MIX2OUT,
WM8753_MIX2OUT
);
if( WM_ERROR( status ) )
{
goto error;
}
/*
* Enable RM Signal to Right Mixer.
*/
status = WMSetField( hDevice,
WM8753_RIGHT_OUT_MIX_1,
WM8753_MIX2OUT,
WM8753_MIX2OUT
);
if( WM_ERROR( status ) )
{
goto error;
}
return WMS_SUCCESS;
error:
return status;
}
/*-----------------------------------------------------------------------------
* Function: WM8753ClearLineInRecPaths
*
* Turns off Line In to ADC 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 WM8753ClearLineInRecPaths( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL lineInL,
WM_AUDIO_SIGNAL lineInR
)
{
WMSTATUS status;
/*
* Mute Left ADC Volume.
*/
status = WMWrite( hDevice,
WM8753_LEFT_ADC_VOLUME,
WM8753_ADCVOL_MUTE
);
if( WM_ERROR( status ) )
{
goto error;
}
/*
* Mute Right ADC Volume.
*/
status = WMWrite( hDevice,
WM8753_RIGHT_ADC_VOLUME,
WM8753_VOLUME_UPDATE |
WM8753_ADCVOL_MUTE
);
if( WM_ERROR( status ) )
{
goto error;
}
/*
* Disable LM Signal to Left Mixer.
*/
status = WMClearField( hDevice,
WM8753_LEFT_OUT_MIX_1,
WM8753_MIX2OUT
);
if( WM_ERROR( status ) )
{
goto error;
}
/*
* Disable RM Signal to Reft Mixer.
*/
status = WMClearField( hDevice,
WM8753_RIGHT_OUT_MIX_1,
WM8753_MIX2OUT
);
if( WM_ERROR( status ) )
{
goto error;
}
return WMS_SUCCESS;
error:
return status;
}
/*-----------------------------------------------------------------------------
* Function: WM8753SetMicRecPaths
*
* Set up MIC1 path to the ADC left and/or MIC2 to ADC right as the record path.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* micSignalL left channel microphone input to use.
* micSignalR right channel microphone input to use.
*
* Returns: WMSTATUS
* See WMStatus.h
*---------------------------------------------------------------------------*/
WMSTATUS WM8753SetMicRecPaths( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL micSignalL,
WM_AUDIO_SIGNAL micSignalR
)
{
WMSTATUS status;
WM_REGVAL value;
WM_REGVAL mask;
/*
* This should be checked higher up.
*/
WM_ASSERT( hDevice, !( WM_AUDIO_IGNORE == micSignalL && WM_AUDIO_IGNORE == micSignalR ) );
/*
* Set Left ADC Volume.
*/
if ( WM_AUDIO_IGNORE != micSignalL )
{
value = WM8753_ADCVOL_0DB;
if ( WM_AUDIO_IGNORE == micSignalR )
value |= WM8753_VOLUME_UPDATE;
status = WMWrite( hDevice,
WM8753_LEFT_ADC_VOLUME,
value
);
if ( WM_ERROR( status ) )
{
goto error;
}
/*
* Select appropriate mics to ALC - left channel - and to sidetone.
* Note MIC2 automatically goes to the right channel.
*/
status = WMSetField( hDevice,
WM8753_INPUT_CONTROL_2,
WM8753_MIC1ALC | WM8753_MICMUX_MIC1,
WM8753_MIC1ALC | WM8753_MIC2ALC | WM8753_MICMUX_MASK
);
if ( WM_ERROR( status ) )
{
goto error;
}
}
/*
* Set Right ADC Volume.
*/
if ( WM_AUDIO_IGNORE != micSignalR )
{
status = WMWrite( hDevice,
WM8753_RIGHT_ADC_VOLUME,
WM8753_VOLUME_UPDATE |
WM8753_ADCVOL_0DB
);
if ( WM_ERROR( status ) )
{
goto error;
}
if ( WM_AUDIO_IGNORE == micSignalL )
{
/*
* No MIC1, so select MIC2 to sidetone.
* Note MIC2 automatically goes to the right channel.
*/
status = WMSetField( hDevice,
WM8753_INPUT_CONTROL_2,
WM8753_MICMUX_MIC2,
WM8753_MICMUX_MASK
);
if ( WM_ERROR( status ) )
{
goto error;
}
}
}
/*
* Set the ADC input mode to PGA.
*/
value = mask = 0;
if ( WM_AUDIO_IGNORE != micSignalL )
{
value |= WM8753_LEFTADCSEL_PGA;
mask |= WM8753_LEFTADCSEL_MASK;
}
if ( WM_AUDIO_IGNORE != micSignalR )
{
value |= WM8753_RIGHTADCSEL_PGA;
mask |= WM8753_RIGHTADCSEL_MASK;
}
status = WMSetField( hDevice, WM8753_ADC_INPUT_MODE, value, mask );
if ( WM_ERROR( status ) )
{
goto error;
}
/*
* Make sure our MIC amps are enabled.
*/
value = 0;
if ( WM_AUDIO_IGNORE != micSignalL )
{
value |= WM8753_PWR2_MICAMP1EN;
}
if ( WM_AUDIO_IGNORE != micSignalR )
{
value |= WM8753_PWR2_MICAMP2EN;
}
status = WMSetField( hDevice, WM8753_PWR_MGMT_2, value, value );
if ( WM_ERROR( status ) )
{
goto error;
}
/*
* Set 30dB mic boost.
*/
value = mask = 0;
if ( WM_AUDIO_IGNORE != micSignalL )
{
value |= WM8753_MIC1BOOST_30DB;
mask |= WM8753_MIC1BOOST_MASK;
}
if ( WM_AUDIO_IGNORE != micSignalR )
{
value |= WM8753_MIC2BOOST_30DB;
mask |= WM8753_MIC2BOOST_MASK;
}
status = WMSetField( hDevice, WM8753_INPUT_CONTROL_1, value, mask );
if ( WM_ERROR( status ) )
{
goto error;
}
/*
* Set up ALC for voice.
* Fortunately WM8753_ALC_STEREO = WM8753_ALC_LEFT | WM8753_ALC_RIGHT
*/
value = 0;
if ( WM_AUDIO_IGNORE != micSignalL )
value |= WM8753_ALC_LEFT;
if ( WM_AUDIO_IGNORE != micSignalR )
value |= WM8753_ALC_RIGHT;
status = WMWrite( hDevice, WM8753_ALC_1, WM8753_ALC1_VOICE | value );
if ( WM_ERROR( status ) )
{
goto error;
}
status = WMSetField( hDevice, WM8753_ALC_2, WM8753_ALC2_VOICE, WM8753_ALC2_PROFILE_MASK );
if ( WM_ERROR( status ) )
{
goto error;
}
status = WMWrite( hDevice, WM8753_ALC_3, WM8753_ALC3_VOICE );
if ( WM_ERROR( status ) )
{
goto error;
}
status = WMWrite( hDevice, WM8753_NOISE_GATE, WM8753_NOISE_GATE_VOICE );
if ( WM_ERROR( status ) )
{
goto error;
}
/*
* Enable ST Signal to Left Mixer.
*/
if ( WM_AUDIO_IGNORE != micSignalL )
{
status = WMSetField( hDevice,
WM8753_LEFT_OUT_MIX_2,
WM8753_ST2OUT,
WM8753_ST2OUT
);
if ( WM_ERROR( status ) )
{
goto error;
}
}
/*
* Enable ST Signal to Right Mixer.
*/
if ( WM_AUDIO_IGNORE != micSignalR )
{
status = WMSetField( hDevice,
WM8753_RIGHT_OUT_MIX_2,
WM8753_ST2OUT,
WM8753_ST2OUT
);
if ( WM_ERROR( status ) )
{
goto error;
}
}
/*
* Enable ST Signal to Mono Mixer.
*/
status = WMSetField( hDevice,
WM8753_MONO_OUT_MIX_2,
WM8753_ST2OUT,
WM8753_ST2OUT
);
if ( WM_ERROR( status ) )
{
goto error;
}
return WMS_SUCCESS;
error:
return status;
}
/*-----------------------------------------------------------------------------
* Function: WM8753ClearMicRecPaths
*
* Turns off the MIC1 record path.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* micSignalL left channel microphone input to clear.
* micSignalR right channel microphone input to clear.
*
* Returns: WMSTATUS
* See WMStatus.h
*---------------------------------------------------------------------------*/
WMSTATUS WM8753ClearMicRecPaths( WM_DEVICE_HANDLE hDevice,
WM_AUDIO_SIGNAL micSignalL,
WM_AUDIO_SIGNAL micSignalR
)
{
WMSTATUS status;
WM_REGVAL mask = 0;
/*
* This should be checked higher up.
*/
WM_ASSERT( hDevice, !( WM_AUDIO_IGNORE == micSignalL && WM_AUDIO_IGNORE == micSignalR ) );
/*
* Mute Left ADC Volume.
*/
if ( WM_AUDIO_IGNORE != micSignalL )
{
status = WMWrite( hDevice,
WM8753_LEFT_ADC_VOLUME,
WM8753_ADCVOL_MUTE
);
if( WM_ERROR( status ) )
{
goto error;
}
}
/*
* Mute Right ADC Volume.
*/
if ( WM_AUDIO_IGNORE != micSignalR )
{
status = WMWrite( hDevice,
WM8753_RIGHT_ADC_VOLUME,
WM8753_VOLUME_UPDATE |
WM8753_ADCVOL_MUTE
);
if( WM_ERROR( status ) )
{
goto error;
}
}
/*
* Make sure our MIC amps are disabled.
*/
mask = 0;
if ( WM_AUDIO_IGNORE != micSignalL )
{
mask |= WM8753_PWR2_MICAMP1EN;
}
if ( WM_AUDIO_IGNORE != micSignalR )
{
mask |= WM8753_PWR2_MICAMP2EN;
}
status = WMClearField( hDevice,
WM8753_PWR_MGMT_2,
mask
);
if ( WM_ERROR( status ) )
{
goto error;
}
/*
* Disable ST Signal to Left Mixer.
*/
if ( WM_AUDIO_IGNORE != micSignalL )
{
status = WMClearField( hDevice,
WM8753_LEFT_OUT_MIX_2,
WM8753_ST2OUT
);
if ( WM_ERROR( status ) )
{
goto error;
}
}
/*
* Disable ST Signal to Right Mixer.
*/
if ( WM_AUDIO_IGNORE != micSignalR )
{
status = WMClearField( hDevice,
WM8753_RIGHT_OUT_MIX_2,
WM8753_ST2OUT
);
if ( WM_ERROR( status ) )
{
goto error;
}
}
/*
* Disable ST Signal to Mono Mixer.
*/
status = WMClearField( hDevice,
WM8753_MONO_OUT_MIX_2,
WM8753_ST2OUT
);
if ( WM_ERROR( status ) )
{
goto error;
}
return WMS_SUCCESS;
error:
return status;
}
#endif /* WM_AUDIO && WM8753_FAMILY */
/*------------------------------ END OF FILE ---------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -