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

📄 wmaudiopaths.c

📁 WM9713 audio codec driver for WinCE 5.0
💻 C
📖 第 1 页 / 共 4 页
字号:
        {
            status = WMAudioUnconfigurePath( hDevice, WM_STREAM_HIFI_OUT );
        }
    }

    if ( WM_IS_AC97( hDevice ) )
    {
        /*
         * Enable all the mixers to all their specific outputs
         */
        status = private_enableMixersToOutputs( hDevice, enable );
        if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
        {
            goto error;
        }
    }

    /* 
     * Mute/unmute the HiFi DAC
     */
    status = WMAudioMuteSignal( hDevice, WM_AUDIO_HIFI_DAC, mute );
    if ( WM_ERROR( status ) )
    {
        goto error;
    }

	return status;

error:
        WM_TRACE( hDevice,
                  ( "WMAudioEnableHiFiOutputPath failed to %s path: %s",
                    enable ? "enable" : "disable",
                    WMStatusText( status )
                  ) 
                );

	return status;
}

#if WM_VOICE
/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableVoiceOutputPaths
 *
 * Enables the path from the Voice DAC to all outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableVoiceOutputPaths( WM_DEVICE_HANDLE hDevice )
{
    return private_EnableVoiceOutputPaths( hDevice, TRUE );
}

/*-----------------------------------------------------------------------------
 * Function:    private_EnableVoiceOutputPaths
 *
 * Enables the path from the Voice DAC to all outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS private_EnableVoiceOutputPaths( WM_DEVICE_HANDLE hDevice,
                                         WM_BOOL enable
                                       )
{
    WMSTATUS status = WMS_UNSUPPORTED;
    WM_BOOL  mute   = !enable;

    if ( !WM_HAS_VOICE_DAC( hDevice ) )
    {
        goto error;
    }
    if ( WM_IS_I2S( hDevice ) )
    {
        /*
         * Try using the generic function first.
         */
        if ( enable )
        {
            status = WMAudioConfigurePath( hDevice, WM_STREAM_VOICE_OUT );
        }
        else
        {
            status = WMAudioUnconfigurePath( hDevice, WM_STREAM_VOICE_OUT );
        }
    }

    if ( IS_WM9713_FAMILY( hDevice ) )
    {
        if ( enable )
        {
            status = WMWrite( hDevice,
                              WM9713_VXDAC_VOLUME,
                              ( WM97_VXDAC_MONO_VOL( WM97_PGA_VOL_0DB ) |
                                WM97_VXDAC_SPEAKER_VOL( WM97_PGA_VOL_0DB ) |
                                WM97_VXDAC_HEADPHONE_VOL( WM97_PGA_VOL_0DB )
                              )
                            );
            if ( WM_ERROR( status ) )
            {
                goto error;
            }
        }
        else
        {
            status = WMWrite( hDevice,
                              WM9713_VXDAC_VOLUME,
                              WM97_STANDARD_MUTE
                            );
            if ( WM_ERROR( status ) )
            {
                goto error;
            }
        }
    }

    if ( WM_IS_AC97( hDevice ) )
    {
        /* 
         * Mute/unmute the Voice DAC
         */
        status = WMAudioMuteSignal( hDevice, WM_AUDIO_VOICE_DAC, mute );
        if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
        {
            goto error;
        }

        /*
         * Enable all the mixers to all their specfic outputs
         */
        status = private_enableMixersToOutputs( hDevice, enable );
        if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
        {
            goto error;
        }
    }

	return status;

error:
    if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
    {
            WM_TRACE( hDevice,
                      ( "WMAudioEnableVoiceOutputPath failed to %s path: %s",
                        enable ? "enable" : "disable",
                        WMStatusText( status )
                      ) 
                    );
    }

    return status;
}
#endif /* WM_VOICE */

#if WM_MONODAC
/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableMonoOutputPaths
 *
 * Enables the path from the Mono DAC to all outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableMonoOutputPaths( WM_DEVICE_HANDLE hDevice )
{
    return private_EnableMonoOutputPaths( hDevice, TRUE );
}

/*-----------------------------------------------------------------------------
 * Function:    private_EnableMonoOutputPaths
 *
 * Enables the path from the Mono DAC to all outputs (MONO).
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
static WMSTATUS private_EnableMonoOutputPaths( WM_DEVICE_HANDLE hDevice,
                                               WM_BOOL enable
                                             )
{
    WMSTATUS status = WMS_UNSUPPORTED;
    WM_BOOL  mute   = !enable;

    if ( !WM_HAS_MONO_DAC( hDevice ) )
    {
        goto error;
    }
    
    if ( WM_IS_I2S( hDevice ) )
    {
        /*
         * Try using the generic function first.
         */
        if ( enable )
        {
            status = WMAudioConfigurePath( hDevice, WM_STREAM_MONO_OUT );
        }
        else
        {
            status = WMAudioUnconfigurePath( hDevice, WM_STREAM_MONO_OUT );
        }
    }
    
    if( WM_IS_AC97( hDevice ) )
    {
        WM_REGTYPE MonoDACReg;
        WM_REGVAL  MonoDACEnable;

        if ( IS_WM9712_FAMILY( hDevice ) )
        {
            MonoDACReg = WM97_AUXDAC_VOLUME;
            MonoDACEnable = WM97_AUXDAC_ENABLE; 
        }

        if ( IS_WM9713_FAMILY( hDevice ) )
        {
            MonoDACReg = WM9713_AUXDAC_VOLUME;
            MonoDACEnable = 0; 

        }

        if ( enable )
        {
            /* Enable AUXDAC across slot 5 */
            status = WMWrite( hDevice,
                              WM97_AUXDAC_INPUT_CONTROL,
                              ( WM97_AUXDAC_FROM_SLOT |
                                WM97_AUXDAC_SLOT_5 )
                            );
            if ( WM_ERROR( status ) )
            {
                goto error;
            }


            status = WMWrite( hDevice, 
                              MonoDACReg, 
                              ( WM97_AUX_PHONE_VOL( WM97_PGA_VOL_0DB )     |
                                WM97_AUX_SPEAKER_VOL( WM97_PGA_VOL_0DB )   |
                                WM97_AUX_HEADPHONE_VOL( WM97_PGA_VOL_0DB ) |
                                MonoDACEnable
                              )
                            );
            if ( WM_ERROR( status ) )
            {
                goto error;
            }

        }
        else
        {
            status = WMWrite( hDevice, MonoDACReg, WM97_STANDARD_MUTE );
            if ( WM_ERROR( status ) )
            {
                goto error;
            }
        }

        /*
         * Enable all the mixers to all their specifc outputs
         */
        status = private_enableMixersToOutputs( hDevice, enable );
        if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
        {
            goto error;
        }

        /* 
         * Mute/unmute the Mono DAC
         */
        status = WMAudioMuteSignal( hDevice, WM_AUDIO_MONO_DAC, mute );
        if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
        {
            goto error;
        }

    }

	return status;

error:
    if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
    {
            WM_TRACE( hDevice,
                      ( "WMAudioEnableMonoOutputPath failed to %s path: %s",
                        enable ? "enable" : "disable",
                        WMStatusText( status )
                      ) 
                    );
    }

    return status;
}
#endif /* WM_MONODAC */

/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableInputPaths
 *
 * Enables/disables the path from the inputs to the given streams ADC.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      ifStream        the stream to enable/disable
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableInputPaths( WM_DEVICE_HANDLE hDevice,
                                  WM_STREAM_ID     ifStream,
                                  WM_BOOL          enable
                                )
{
    WMSTATUS        status = WMS_UNSUPPORTED;
    WM_STREAM_ID    stream = _WMAudioGetRealStream( hDevice, ifStream );

    /*
     * Check our stream.
     */
    if ( !WM_IS_INPUT_STREAM( stream ) )
    {
        goto error;
    }

    switch ( stream )
    {
        case WM_STREAM_HIFI_IN:
            status = private_EnableHiFiInputPaths( hDevice, enable );
            break;

#if WM_VOICE
        case WM_STREAM_VOICE_IN:
            status = private_EnableVoiceInputPaths( hDevice, enable );
            break;
#endif /* WM_VOICE */

        default:
            /* We checked we had a valid output stream above */
            WM_ASSERT( hDevice, WM_IS_INPUT_STREAM( stream ) );
			goto error;
    }

    return WMS_SUCCESS;

error:

    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    private_EnableHiFiInputPaths
 *
 * Enables/disables the path from the inputs to the HiFi ADC.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
static WMSTATUS private_EnableHiFiInputPaths( WM_DEVICE_HANDLE hDevice,
                                              WM_BOOL enable
                                            )
{
    WMSTATUS status = WMS_UNSUPPORTED;
    WM_BOOL  mute   = !enable;

    if ( WM_IS_I2S( hDevice ) )
    {
        /*
         * Try using the generic function first.
         */
        if ( enable )
        {
            status = WMAudioConfigurePath( hDevice, WM_STREAM_HIFI_IN );
        }
        else
        {
            status = WMAudioUnconfigurePath( hDevice, WM_STREAM_HIFI_IN );
        }
    }

    /* 
     * Mute/unmute the HiFi ADC
     */
    status = WMAudioMuteSignal( hDevice, WM_AUDIO_HIFI_ADC, mute );
    if ( WM_ERROR( status ) )
    {
        goto error;
    }

	return status;

error:
        WM_TRACE( hDevice,
                  ( "WMAudioEnableHiFiInputPath failed to %s path: %s",
                    enable ? "enable" : "disable",
                    WMStatusText( status )
                  ) 
                );

	return status;
}

#if WM_VOICE
/*-----------------------------------------------------------------------------
 * Function:    private_EnableVoiceInputPaths
 *
 * Enables/disables the path from the inputs to the Voice ADC.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
static WMSTATUS private_EnableVoiceInputPaths( WM_DEVICE_HANDLE hDevice,
                                               WM_BOOL enable
                                             )
{
    WMSTATUS status = WMS_UNSUPPORTED;
    WM_BOOL  mute   = !enable;

    if ( WM_IS_I2S( hDevice ) )
    {
        /*
         * Try using the generic function first.
         */
        if ( enable )
        {
            status = WMAudioConfigurePath( hDevice, WM_STREAM_VOICE_IN );
        }
        else
        {
            status = WMAudioUnconfigurePath( hDevice, WM_STREAM_VOICE_IN );
        }
    }

    /* 
     * Mute/unmute the Voice ADC
     */
    status = WMAudioMuteSignal( hDevice, WM_AUDIO_VOICE_ADC, mute );
    if ( WM_ERROR( status ) )
    {
        goto error;
    }

	return status;

error:
        WM_TRACE( hDevice,
                  ( "WMAudioEnableVoiceInputPath failed to %s path: %s",
                    enable ? "enable" : "disable",
                    WMStatusText( status )
                  ) 
                );

	return status;
}
#endif /* WM_VOICE */
#endif  /* WM_AUDIO */

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

⌨️ 快捷键说明

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