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

📄 wm97audiopaths.c

📁 WM9713 audio codec driver for WinCE 5.0
💻 C
📖 第 1 页 / 共 2 页
字号:

    /* Select Mic */
    status = WMAudioSelectMics( hDevice, micSignalL, micSignalR );
    if ( WM_ERROR( status ) )
    {
        WM_TRACE( hDevice,
                  ( "WM97SetMicRecPaths - Mic select failed: 0%s",
                  WMStatusText( status ) ) );
        goto exit;
    }

    /* Increase Mic signal to that of a line level */
    status = WMAudioMicRecNormalise( hDevice, micSignalL, micSignalR, TRUE );
    if ( WM_ERROR( status ) )
    {
        WM_TRACE( hDevice,
                  ( "WM97SetMicRecPaths - Increasing Mic output to line level 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,
                      ( "WM97SetMicRecPaths - 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_0DB, 
                             WM9712_SIDETONE_MIC_MUTE | WM9712_SIDETONE_ALC_MUTE_MASK 
                           );
        if ( WM_ERROR( status ) )
        {
            WM_TRACE( hDevice,
                      ( "WM97SetMicRecPaths Enabling sidetone failed: %s",
                      WMStatusText( status ) ) );
            goto exit;
        }
    }

    if ( IS_WM9713_FAMILY( hDevice ) )
    {
		WM_REGVAL micMute = 0;
		
		/* 
		 * Turn on MIC2A and MIC2B pre-amps (also used by MIC1).
		 * Note : WMPowerUp does not have the resolution to powerdown 
		 * the MIC pre-amps and PGAs individually.
		 */
		WM_REGVAL value=0;
		WM_REGVAL mask=0;

		/* Check to see if any Mic inputs need to use A's pre-amp and PGA */
		if ( WM_MIC_SIGNAL_USES_A( micSignalL ) || WM_MIC_SIGNAL_USES_A( micSignalR ) )
		{
			value |= WM9713_EXTPWR_MIC_A;
			mask  |= WM9713_EXTPWR_MIC_A;
			value |= WM9713_EXTPWR_MIC_PREAMP_A;
			mask  |= WM9713_EXTPWR_MIC_PREAMP_A;
		}
		/* Check to see if any Mic inputs need to use B's pre-amp and PGA */
		if ( !WM_MIC_SIGNAL_USES_A( micSignalL ) || !WM_MIC_SIGNAL_USES_A( micSignalR ) )
		{
			value |= WM9713_EXTPWR_MIC_B;
			mask  |= WM9713_EXTPWR_MIC_B;
			value |= WM9713_EXTPWR_MIC_PREAMP_B;
			mask  |= WM9713_EXTPWR_MIC_PREAMP_B;
		}

		status = WMClearField( hDevice, 
                               WM9713_EXT_POWERDOWN_2,
							   ( WM9713_EXTPWR_MIC_PREAMP_B |
								 WM9713_EXTPWR_MIC_PREAMP_A |
								 WM9713_EXTPWR_MIC_B        |
								 WM9713_EXTPWR_MIC_A
							   )
							 );
		if ( WM_ERROR( status ) )
		{
            WM_TRACE( hDevice,
                      ( "WM97SetMicRecPaths - power up of mic pre-amps failed: %s",
                      WMStatusText( status ) ) );
			goto exit;
		}

		/* Mute headphone and unmute selected signals */
		micMute |= WM9713_MIC_MUTE;
		/* Route MIC X to Headphone */
		if ( WM_AUDIO_MIC2A == micSignalL || WM_AUDIO_MIC1 == micSignalL ||
			 WM_AUDIO_MIC2A == micSignalR || WM_AUDIO_MIC1 == micSignalR ||
			 WM_AUDIO_MIC2BTOA == micSignalR || WM_AUDIO_MIC2BTOA == micSignalR )
		{
			/* MIC 1 can only use MIC2A's pre-amp */
			micMute &= ~WM9713_MIC2H_NO_MICA;
		}

		if ( WM_AUDIO_MIC2B == micSignalL )
		{
			micMute &= ~WM9713_MIC2H_NO_MICB;
		}

		status = WMClearField( hDevice, WM9713_MIC_ROUTING, micMute );
		if ( WM_ERROR( status ) )
		{
            WM_TRACE( hDevice,
                      ( "WM97SetMicRecPaths - Mic routing failed: %s",
                      WMStatusText( status ) ) );
			goto exit;
		}
		
		/* Set headphone MIC vol.  (We are using the default value (0dB)) */
        status = WMSetField( hDevice, 
							 WM9713_MIC_ROUTING, 
							 WM9713_MIC2H_0DB_VOL, 
							 WM9713_MIC2H_VOL_MASK 
						   );
        if ( WM_ERROR( status ) )
        {
            WM_TRACE( hDevice,
                      ( "WM97SetMicRecPaths - Setting headphone mic volume failed: %s",
                      WMStatusText( status ) ) );
            goto exit;
        }
    } 

exit:
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WM97ClearMicRecPaths
 *
 * Turns off the given microphone 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 WM97ClearMicRecPaths( WM_DEVICE_HANDLE hDevice,
							   WM_AUDIO_SIGNAL  micSignalL,
							   WM_AUDIO_SIGNAL  micSignalR 
							 )
{
	WMSTATUS status;

	/* 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 Mic signal back to 0dB */
    status = WMAudioMicRecNormalise( hDevice, micSignalL, micSignalR, FALSE );
    if ( WM_ERROR( status ) )
    {
        WM_TRACE( hDevice,
                  ( "WM97ClearMicRecPaths - Disabling Mic normalisation failed: %s",
                  WMStatusText( status ) ) );
        goto exit;
    }

    /* Make the ADC input include the DAC output again */
    if ( IS_WM9705_FAMILY( hDevice ) || IS_WM9707_FAMILY( hDevice ) )
    {
        status = WMClearField( hDevice, WM97_ADD_FUN_CONTROL, WM9705_ADDFUN_ADCNDAC );
        if ( WM_ERROR( status ) )
        {
            WM_TRACE( hDevice,
                      ( "WM97ClearMicRecPaths - Adding back DAC signal to ADC input failed: %s",
                      WMStatusText( status ) ) );
            goto exit;
        }
	}

    /* Mute the sidetone path */
    if ( IS_WM9712_FAMILY( hDevice ) )
    {
		status = WMSetField( hDevice,
                             WM97_SIDETONE_VOLUME, 
							 WM9712_SIDETONE_MIC_MUTE | WM9712_SIDETONE_ALC_MUTE, 
                             WM9712_SIDETONE_MIC_MUTE | WM9712_SIDETONE_ALC_MUTE_MASK
                           );
        if ( WM_ERROR( status ) )
        {
            WM_TRACE( hDevice,
                      ( "WM97ClearMicRecPaths - Disabling sidetone failed: %s",
                      WMStatusText( status ) ) );
            goto exit;
        }
	}

	if ( IS_WM9713_FAMILY( hDevice ) )
	{		
		/* 
		 * Turn off MIC2A and MIC2B pre-amps
		 * Note : WMPowerDown does not have the resolution to powerdown 
		 * the MIC pre-amps and PGAs individually.
		 */
		WM_REGVAL value=0;
		WM_REGVAL mask=0;

		/* Check to see if any Mic inputs are using A's pre-amp and PGA */
		if ( WM_MIC_SIGNAL_USES_A( micSignalL ) || WM_MIC_SIGNAL_USES_A( micSignalR ) )
		{
			value |= WM9713_EXTPWR_MIC_A;
			mask  |= WM9713_EXTPWR_MIC_A;
			value |= WM9713_EXTPWR_MIC_PREAMP_A;
			mask  |= WM9713_EXTPWR_MIC_PREAMP_A;
		}
		/* Check to see if any Mic inputs are using A's pre-amp and PGA */
		if ( !WM_MIC_SIGNAL_USES_A( micSignalL ) || !WM_MIC_SIGNAL_USES_A( micSignalR ) )
		{
			value |= WM9713_EXTPWR_MIC_B;
			mask  |= WM9713_EXTPWR_MIC_B;
			value |= WM9713_EXTPWR_MIC_PREAMP_B;
			mask  |= WM9713_EXTPWR_MIC_PREAMP_B;
		}

		status = WMSetField( hDevice,
                             WM9713_EXT_POWERDOWN_2,
							 value,
							 mask
						   );
		if ( WM_ERROR( status ) )
		{
            WM_TRACE( hDevice,
                      ( "WM97ClearMicRecPaths - Power down of mic pre-amps failed: %s",
                      WMStatusText( status ) ) );
			goto exit;
		}
	}

exit:
	return status;
}

#endif  /* WM_AUDIO && WM_AC97 */

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

⌨️ 快捷键说明

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