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

📄 hwctxt.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            // DMA request is generated. Therefore, this value is also the
            // number of words that we should transfer using a single DMA
            // operation to try and refill the FIFO.
            m_OutputDMALevel = SSI_SFCSR_TX_WATERMARK;
            
            // Open the DMA channel for handling SSI transmit/playback.
            m_OutputDMAChan = DDKSdmaOpenChan((STEREO_DAC_SSI == m_pSSI1) ?
                                                  DDK_DMA_REQ_SSI1_TX0 :
                                                  DDK_DMA_REQ_SSI2_TX0, 
                                              BSP_SDMA_CHNPRI_AUDIO, NULL, 
                                              (STEREO_DAC_SSI == m_pSSI1) ?
                                                  IRQ_SSI1 : IRQ_SSI2);

            if (m_OutputDMAChan) rc = TRUE;
            
            break;
    }

    return rc;
}

#ifdef AUDIO_RECORDING_ENABLED

//-----------------------------------------------------------------------------
//
//  Function: BSPAudioInitInput
//
//  This function initializes the DMA, SSI, and AUDMUX to support audio 
//  input.
//
//  Parameters:
//      The SSI configuration to be used.
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
BOOL HardwareContext::BSPAudioInitInput(AUDIO_BUS bus)
{
    BOOL rc = FALSE;
            
    switch (bus)
    {
        case AUDIO_BUS_VOICE_IN:
            
            // Configure the SSI to function as the audio input channel.
            BSPAudioInitSsi(bus, VOICE_CODEC_SSI);
            
            // Configure the PMIC Voice CODEC.
            BSPAudioInitCodec(bus);
            
            // Configure the AUDMUX to route the SSI to the PMIC Voice Codec.
            //
            // We need to do this last (and only after both the SSI and PMIC
            // has been properly configured) to avoid any possible signal
            // conflicts due to any previous SSI and/or PMIC configuration
            // settings.
            BSPAudioRoute((VOICE_CODEC_SSI == m_pSSI1) ? SSI1_AUDMUX_PORT :
                                                         SSI2_AUDMUX_PORT,
                          VOICE_CODEC_AUDMUX_PORT,
                          (VOICE_CODEC_SSI == m_pSSI1) ? BSP_SSI1_MASTER_BOOL :
                                                         BSP_SSI2_MASTER_BOOL);
            
            // Configure the input DMA watermark level. This value is the
            // number of words currently stored in the SSI receiver FIFO
            // before a DMA request is sent. Therefore, this is also the
            // number of words that we will read (and remove) from the FIFO
            // using a single DMA operation.
            m_InputDMALevel = SSI_SFCSR_RX_WATERMARK;
            
            // Open the DMA channel for handling SSI receive/recording.
            m_InputDMAChan = DDKSdmaOpenChan((VOICE_CODEC_SSI == m_pSSI1) ?
                                                 DDK_DMA_REQ_SSI1_RX0 :
                                                 DDK_DMA_REQ_SSI2_RX0, 
                                             BSP_SDMA_CHNPRI_AUDIO, NULL,
                                             (VOICE_CODEC_SSI == m_pSSI1) ?
                                                 IRQ_SSI1 : IRQ_SSI2);

            if (m_InputDMAChan) rc = TRUE;

            break;
    }

    return rc;
}

#endif // #ifdef AUDIO_RECORDING_ENABLED


//-----------------------------------------------------------------------------
//
//  Function: BSPAudioStartOutput
//
//  This function configures audio output devices to start audio playback.
//
//  Parameters:
//      The SSI configuration to be used.
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
BOOL HardwareContext::BSPAudioStartOutput(AUDIO_BUS bus, AUDIO_PATH path,
                                          const HWSAMPLE *const ssiFifoPrefill,
                                          const unsigned nSsiFifoPrefill)
{
    BOOL rc = TRUE;
    
    switch (bus)
    {
        case AUDIO_BUS_STEREO_OUT:

            // Turn on the codec and amps. This must be done before starting
            // SSI output because there are required delays involved in
            // enabling some of the PMIC audio components. These required
            // delays will cause an SSI FIFO underrun error if the SSI
            // transmitter is already running before the PMIC audio components
            // have been enabled.
            BSPAudioStartCodecOutput(bus, path);

            // Start the SSI transmitter.
            BSPAudioStartSsiOutput(STEREO_DAC_SSI, ssiFifoPrefill,
                                   nSsiFifoPrefill);

            break;
    }

    return rc;
}


#ifdef AUDIO_RECORDING_ENABLED

//-----------------------------------------------------------------------------
//
//  Function: BSPAudioStartInput
//
//  This function configures audio input devices to start audio record.
//
//  Parameters:
//      The SSI configuration to be used.
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
BOOL HardwareContext::BSPAudioStartInput(AUDIO_BUS bus, AUDIO_PATH path)
{
    BOOL rc = TRUE;
    
    switch (bus)
    {
        case AUDIO_BUS_VOICE_IN:

            // Start SSI receive
            BSPAudioStartSsiInput(VOICE_CODEC_SSI);

            // Turn on the codec and amps
            BSPAudioStartCodecInput(bus, path);

            break;
    }

    return rc;
}

#endif // #ifdef AUDIO_RECORDING_ENABLED


//-----------------------------------------------------------------------------
//
//  Function: BSPAudioStopOutput
//
//  This function configures audio output devices to stop audio playback.
//
//  Parameters:
//      The SSI configuration to be used.
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
BOOL HardwareContext::BSPAudioStopOutput(AUDIO_BUS bus, AUDIO_PATH path)
{
    BOOL rc = TRUE;
    
    switch (bus)
    {
        case AUDIO_BUS_STEREO_OUT:

            // Turn off the codec and amps
            BSPAudioStopCodecOutput(bus, path);        
            
            // Stop SSI transmit
            BSPAudioStopSsiOutput(STEREO_DAC_SSI);

            break;
    }

    return rc;
}


#ifdef AUDIO_RECORDING_ENABLED

//-----------------------------------------------------------------------------
//
//  Function: BSPAudioStopInput
//
//  This function configures audio input devices to stop audio record.
//
//  Parameters:
//      The SSI configuration to be used.
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
BOOL HardwareContext::BSPAudioStopInput(AUDIO_BUS bus, AUDIO_PATH path)
{
    BOOL rc = TRUE;
    
    switch (bus)
    {
        case AUDIO_BUS_VOICE_IN:

            // Turn off the codec and amps
            BSPAudioStopCodecInput(bus, path);
            
            // Stop SSI transmit
            BSPAudioStopSsiInput(VOICE_CODEC_SSI);

            break;
    }

    return rc;
}

#endif // #ifdef AUDIO_RECORDING_ENABLED


//-----------------------------------------------------------------------------
//
//  Function: BSPAudioSetOutputGain
//
//      This function configures the Stereo DAC's output PGA amplifier gain
//      level based upon the volume level that Windows is currently requesting.
//
//      The current mapping uses only the low-word of the DWORD dwGain
//      argument because the PMIC does not allow setting separate gain
//      levels for the left and right channels. Therefore, as documented
//      in the audio driver online help files, we should just use the
//      low-word part of the gain value. This provides a range of 0-65535.
//
//      Note that the MC13783 PMIC Stereo DAC supports 14 distinct output
//      gain levels that range from -33dB to +6dB in 3dB steps. Therefore,
//      we have implemented a linear mapping of the 0-65535 range to the
//      0-13 range in order to select the actual hardware gain level.
//
//  Parameters:
//      bus    [in] Ignored.
//      dwGain [in] The desired output volume level.
//
//  Returns:
//      TRUE  if new output gain was successfully set.
//      FALSE if new output gain could not be set.
//
//-----------------------------------------------------------------------------
BOOL HardwareContext::BSPAudioSetOutputGain(AUDIO_BUS bus, const DWORD dwGain)
{
    DWORD lowGain = (dwGain & 0xFFFF);   // Just use low-word of dwGain.
    PMIC_AUDIO_OUTPUT_PGA_GAIN pmicGain;
    PMIC_STATUS rc;

    DEBUGMSG(ZONE_FUNCTION, (_T("+HardwareContext::BSPAudioSetOutputGain\n")));

    if (lowGain <= 2521)
    {
	// Set to minimum amplifier gain.
        pmicGain = OUTPGA_GAIN_MINUS_33DB;
    }
    else if (lowGain > 63013)
    {
	// Set to maximum amplifier gain.
        pmicGain = OUTPGA_GAIN_PLUS_6DB;
    }
    else
    {
	// Linear mapping of lowGain value to available amplifier gain levels.
        pmicGain = (PMIC_AUDIO_OUTPUT_PGA_GAIN)((lowGain - 2522) / 5041 + 1);
    }

    // Set the Stereo DAC's PGA output gain level.
    rc = PmicAudioOutputSetPgaGain(hStDAC, pmicGain);

    DEBUGMSG(ZONE_FUNCTION, (_T("-HardwareContext::BSPAudioSetOutputGain\n")));

    return (rc == PMIC_SUCCESS);
}


#ifdef AUDIO_RECORDING_ENABLED

//-----------------------------------------------------------------------------
//
//  Function: BSPAudioSetInputGain
//
//
//  Parameters:
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
BOOL HardwareContext::BSPAudioSetInputGain(AUDIO_BUS bus, const DWORD dwGain)
{
    DEBUGMSG(ZONE_FUNCTION, (_T("+HardwareContext::BSPAudioSetInputGain\n")));

    DEBUGMSG(ZONE_FUNCTION, (_T("-HardwareContext::BSPAudioSetInputGain\n")));

    return TRUE;
}

#endif // #ifdef AUDIO_RECORDING_ENABLED


//-----------------------------------------------------------------------------
//
//  Function: BSPAudioRoute
//
//  This function configures the Audio MUX to connect/disconnect the SSI
//  to the external power management IC.
//
//  Parameters:
//      intPort [in]   Audio MUX internal port for connection to SSI.
//      extPort [in]   Audio MUX external port for connection to PMIC.
//      bMaster [in]   Boolean flag to select SSI Master (if TRUE) or
//                     PMIC Master (if FALSE) modes.
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
void HardwareContext::BSPAudioRoute(AUDMUX_INTERNAL_PORT intPort,

⌨️ 快捷键说明

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