// definitions for the AC97, Intel's Audio Codec 97 Spec

#ifndef __AC97_H
#define __AC97_H

                                           // conections on concert 97
#define  AC97_RESET              0x00      // 
#define  AC97_MASTER_VOL_STEREO  0x02      // Line Out
#define  AC97_HEADPHONE_VOL      0x04      // 
#define  AC97_MASTER_VOL_MONO    0x06      // TAD Output
#define  AC97_MASTER_TONE        0x08      //
#define  AC97_PCBEEP_VOL         0x0a      // none
#define  AC97_PHONE_VOL          0x0c      // TAD Input (mono)
#define  AC97_MIC_VOL            0x0e      // MIC Input (mono)
#define  AC97_LINEIN_VOL         0x10      // Line Input (stereo)
#define  AC97_CD_VOL             0x12      // CD Input (stereo)
#define  AC97_VIDEO_VOL          0x14      // none
#define  AC97_AUX_VOL            0x16      // Aux Input (stereo)
#define  AC97_PCMOUT_VOL         0x18      // Wave Output (stereo)
#define  AC97_RECORD_SELECT      0x1a      //
#define  AC97_RECORD_GAIN        0x1c
#define  AC97_RECORD_GAIN_MIC    0x1e
#define  AC97_GENERAL_PURPOSE    0x20
#define  AC97_3D_CONTROL         0x22
#define  AC97_MODEM_RATE         0x24
#define  AC97_POWER_CONTROL      0x26

// AC97-2.0 registers
#define  AC97_EXT_AUDIO_ID       0x28				
#define  AC97_EXT_AUDIO_CTRL     0x2a	
#define  AC97_PCM_FRONT_RATE     0x2c	
#define  AC97_PCM_SURR_RATE      0x2e
#define  AC97_PCM_LFE_RATE       0x30
#define  AC97_PCM_LR_RATE        0x32
#define  AC97_MIC_RATE           0x34
#define  AC97_6CH_VOL_CLFE       0x36
#define  AC97_6CH_VOL_LRSURR     0x38	

// Modem registers from 0x3C to 0x58 (next 15 enums)

// registers 0x5a - 0x7a are vendor reserved
#define  AC97_MIXER_VOL			 0x72
#define  AC97_VENDOR_ID1         0x7C
#define  AC97_VENDOR_ID2         0x7E

// Known AC97 codec vendors
#define AC97_VENDOR_CRYSTAL      0x43525900  // Crystal Semicondutor "CRY"
#define AC97_VENDOR_TRITECH      0x54524100  // TriTech "TRA"
#define AC97_VENDOR_AKM          0x414B4D00  // Asahi Kasei "AKM"
#define AC97_VENDOR_SIGMATEL     0x83847600  // SigmaTel


// volume control bit defines

#define AC97_MUTE_HI             0x80
#define AC97_MUTE_LO			 0x00
#define AC97_MICBOOST_HI         0x00
#define AC97_MICBOOST_LO         0x40
#define AC97_LEFTVOL_HI          0x07
#define AC97_LEFTVOL_LO          0x3f
#define AC97_RIGHTVOL_HI         0x3f
#define AC97_RIGHTVOL_LO         0x07
#define AC97_FULLVOL_HI          0x07
#define AC97_FULLVOL_LO          0x07

#define AC97_MIXER_HI			 0x1f
#define AC97_RECGAIN	         0x0f

// record mux defines

#define AC97_RECMUX_MIC          0x00
#define AC97_RECMUX_CD           0x01
#define AC97_RECMUX_VIDEO        0x02      // not used
#define AC97_RECMUX_AUX          0x03      
#define AC97_RECMUX_LINE         0x04      
#define AC97_RECMUX_STEREO_MIX   0x05
#define AC97_RECMUX_MONO_MIX     0x06
#define AC97_RECMUX_PHONE        0x07

// sample rate defines
#define AC97_8000_HI             0x1f
#define AC97_8000_LO             0x40
#define AC97_16000_HI            0x3e
#define AC97_16000_LO            0x80
#define AC97_32000_HI            0x7d
#define AC97_32000_LO            0x00
#define AC97_48000_HI            0xbb
#define AC97_48000_LO            0x80

#define AC97_11025_HI            0x2b
#define AC97_11025_LO            0x11
#define AC97_22050_HI            0x56
#define AC97_22050_LO            0x22
#define AC97_44100_HI            0xac
#define AC97_44100_LO            0x44


// general purpose register bit defines

#define AC97_GP_LPBK             0x0080      // Loopback mode
#define AC97_GP_MS               0x0100      // Mic Select 0=Mic1, 1=Mic2
#define AC97_GP_MIX              0x0200      // Mono output select 0=Mix, 1=Mic
#define AC97_GP_RLBK             0x0400      // Remote Loopback - Modem line codec
#define AC97_GP_LLBK             0x0800      // Local Loopback - Modem Line codec
#define AC97_GP_LD               0x1000      // Loudness 1=on
#define AC97_GP_3D               0x2000      // 3D Enhancement 1=on
#define AC97_GP_ST               0x4000      // Stereo Enhancement 1=on
#define AC97_GP_POP              0x8000      // Pcm Out Path, 0=pre 3D, 1=post 3D


// powerdown control and status bit defines

// status
#define AC97_PWR_MDM             0x0010      // Modem section ready
#define AC97_PWR_REF             0x0008      // Vref nominal
#define AC97_PWR_ANL             0x0004      // Analog section ready
#define AC97_PWR_DAC             0x0002      // DAC section ready
#define AC97_PWR_ADC             0x0001      // ADC section ready

// control
#define AC97_PWR_PR0             0x0100      // ADC and Mux powerdown
#define AC97_PWR_PR1             0x0200      // DAC powerdown
#define AC97_PWR_PR2             0x0400      // Output mixer powerdown (Vref on)
#define AC97_PWR_PR3             0x0800      // Output mixer powerdown (Vref off)
#define AC97_PWR_PR4             0x1000      // AC-link powerdown
#define AC97_PWR_PR5             0x2000      // Internal Clk disable
#define AC97_PWR_PR6             0x4000      // HP amp powerdown
#define AC97_PWR_PR7             0x8000      // Modem off - if supported

// useful power states
#define AC97_PWR_D0              0x0000      // everything on
#define AC97_PWR_D1              AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR4
#define AC97_PWR_D2              AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
#define AC97_PWR_D3              AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
#define AC97_PWR_ANLOFF          AC97_PWR_PR2|AC97_PWR_PR3  //analog section off

#define AC97_MIC_VOL_MAX		15
#define AC97_SPK_VOL_MAX		31

#endif // __AC97_H
