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

📄 hwctxt.h

📁 freescale i.mx31 BSP CE5.0全部源码
💻 H
📖 第 1 页 / 共 2 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#pragma once
//
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

   
Module Name:    HWCTXT.H

Abstract:       Platform dependent code for the mixing audio driver.
  
Environment:    Freescale Power Management ICs with WinCE 5.0 or later.
    
-*/
//-----------------------------------------------------------------------------
//
//  Copyright (C) 2005, 2006, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
//  BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
//  Freescale Semiconductor, Inc.
//
//-----------------------------------------------------------------------------

#include "mxarm11.h"
#include <ceddk.h> // Needed for typedef of PHYSICAL_ADDRESS

//-----------------------------------------------------------------------------
// Defines for audio hardware capabilities.

// Select whether audio recording will be supported. Comment out the following
// to remove support for audio recording. This will also reduce the code size
// for the audio driver and the number of DMA buffers that are allocated.

// Now audio in through  WM8951
//#define AUDIO_RECORDING_ENABLED

#ifdef AUDIO_RECORDING_ENABLED

#define INCHANNELS    (1)    // The PMIC Voice CODEC has one input channel.
                             //
                             // Note that the MC13783 PMIC actually has 2
                             // different input/recording paths. One path
                             // supports a mono microphone (audio jack J3 on
                             // the PMIC daughtercard) while the second path
                             // supports a stereo microphone (audio jack J4 on
                             // the daughtercard).
                             //
                             // However, since WinCE does not have any built-in
                             // capability to select different audio recording
                             // paths and devices with different capabilities,
                             // the current audio driver implementation simply
                             // uses the lowest common denominator and only
                             // supports mono recording. You may use the [HKLM\
                             // Drivers\BuiltIn\Audio\PMIC\Config\Recording]
                             // registry key to select which audio input jack
                             // is to be used. But only the left input channel
                             // will be recorded in the current device driver
                             // implementation if the stereo input jack is
                             // selected.
#else

#define INCHANNELS    (0)    // Audio recording capability has been disabled.

#endif // #ifdef AUDIO_RECORDING_ENABLED

#define OUTCHANNELS   (2)    // PMIC Stereo DAC has two output channels.
#define BITSPERSAMPLE (16)    // Voice CODEC and Stereo DAC uses 16 bits/sample

#define INSAMPLERATE  (16000)    // Voice CODEC input at 16 kHz.
#define OUTSAMPLERATE (44100)    // Stereo DAC output at 44.1 kHz.

// Inverse sample rate, in .32 fixed format, with 1 added at bottom to ensure
// round up.
#define INVSAMPLERATE ((UINT32)(((1i64<<32)/OUTSAMPLERATE)+1))

// Define the size of each audio data word. The valid choices are:
//
//     INT8    for 8 bits/word
//     INT16   for 16 bits/word
//     INT32   for 24 bits/word
//
// The correct value to use depends upon the audio CODEC hardware. Note that
// the SSI hardware only supports a maximum of 24 bits/word.
//
// The required definition for the MC13783 and SC5512 PMICs is INT16.
//
// The word size that is defined here is also used to set the corresponding
// SDMA and SSI transfer sizes.
//
typedef INT16 HWSAMPLE;
typedef HWSAMPLE *PHWSAMPLE;

// Set USE_MIX_SATURATE to 1 if you want the mixing code to guard against
// saturation. This costs a couple of extra instructions in the inner
// signal resampling/mixing loop.
#define USE_MIX_SATURATE    (1)

// The code will use the follwing values as saturation points. These values
// should match the word size defined for HWSAMPLE above.
#define AUDIO_SAMPLE_MAX    (32767)
#define AUDIO_SAMPLE_MIN    (-32768)

// Size in bytes of each DMA buffer. We allocate 2 DMA buffers each for audio
// playback and recording.
#define AUDIO_DMA_PAGE_SIZE     4096 // Default 4096 bytes.

//----- Used to track DMA controllers status -----
#define DMA_CLEAR           0x00000000
#define DMA_DONEA           0x00000002
#define DMA_DONEB           0x00000004
#define DMA_BIU             0x00000008 // Determines which buffer is in use:
                                       // A=0, B=1.
#define DMA_STOP            0x00000010 // Stop DMA after buffers exhausted

//----- Used for scheduling DMA transfers -----
#define  OUT_BUFFER_A       0                            
#define  OUT_BUFFER_B       1

#define  IN_BUFFER_A        0
#define  IN_BUFFER_B        1

#define AUDIO_REGKEY_PREFIX TEXT("Drivers\\BuiltIn\\Audio\\PMIC\\Config")

class HardwareContext
{
public:
    static BOOL CreateHWContext(DWORD Index);
    HardwareContext();
    ~HardwareContext();

    void Lock()   {EnterCriticalSection(&m_Lock);}
    void Unlock() {LeaveCriticalSection(&m_Lock);}

    DWORD GetNumInputDevices()
    {
#ifdef AUDIO_RECORDING_ENABLED
        return 1;
#else
        return 0;
#endif
    }
    DWORD GetNumOutputDevices() {return 1;}
    DWORD GetNumMixerDevices()  {return 1;}

    DeviceContext *GetInputDeviceContext(UINT DeviceId)
    {
#ifdef AUDIO_RECORDING_ENABLED
        return &m_InputDeviceContext;
#else
        return NULL;
#endif
    }
    DeviceContext *GetOutputDeviceContext(UINT DeviceId)
    {
        return &m_OutputDeviceContext;
    }

    BOOL Init(DWORD Index);                                        
    BOOL Deinit();

    void PowerUp();
    void PowerDown();

    BOOL        StartOutputDMA();
    void        StopOutputDMA();
    DWORD       GetOutputGain (void);
    MMRESULT    SetOutputGain (DWORD dwVolume);
    BOOL        GetOutputMute (void);
    MMRESULT    SetOutputMute (BOOL fMute);

#ifdef AUDIO_RECORDING_ENABLED

    BOOL        StartInputDMA();
    void        StopInputDMA();
    DWORD       GetInputGain (void);
    MMRESULT    SetInputGain (DWORD dwVolume);
    BOOL        GetInputMute (void);
    MMRESULT    SetInputMute (BOOL fMute);

#endif // #ifdef AUDIO_RECORDING_ENABLED

    void InterruptThread();

    void DisableDelayThread();

protected:
    typedef enum {
        AUDIO_BUS_STEREO_OUT,
        AUDIO_BUS_VOICE_IN
    } AUDIO_BUS;

    typedef enum {
        AUDIO_PATH_EARPIECE,
        AUDIO_PATH_SPEAKER,
        AUDIO_PATH_HEADSET,
        AUDIO_PATH_LINEOUT,
        AUDIO_PATH_LINEIN,
        AUDIO_PATH_MIC
    } AUDIO_PATH;

    typedef enum {
        AUDIO_PWR_STATE_OFF,
        AUDIO_PWR_STATE_STANDBY,
        AUDIO_PWR_STATE_ON
    } AUDIO_PWR_STATE;

    typedef enum {
        PORT1 = 0,
        PORT2 = 1,
        PORT3 = 2,
    } AUDMUX_INTERNAL_PORT;

⌨️ 快捷键说明

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