#ifndef AUDIO_H_
#define AUDIO_H_

#define AUDIO_DACFIFO_ISFULL()     IORD_ALTERA_AVALON_PIO_DATA(AUDIO_BASE)
#define AUDIO_DACFIFO_WRITE(data)  IOWR_ALTERA_AVALON_PIO_DATA(AUDIO_BASE, data)


bool AUDIO_Init(void);
bool AUDIO_SetLeftLineInVol(alt_u8 vol);
bool AUDIO_SetRightLineInVol(alt_u8 vol);
bool AUDIO_SetLeftLineOutVol(alt_u8 vol);
bool AUDIO_SetRightLineOutVol(alt_u8 vol);
bool AUDIO_SetAnaloguesPath(alt_u16 data);
bool AUDIO_SetDigitalPath(alt_u16 data);
bool AUDIO_SetPowerDown(alt_u16 data);
bool AUDIO_SetInterface(alt_u16 data);
bool AUDIO_SetSampling(alt_u16 data);
bool AUDIO_SetActive(bool bActive);
bool AUDIO_Reset(void);


// REG Files
#define REG_AUDIO_LEFT_LINEIN        0   
#define REG_AUDIO_RIGHT_LINEIN       1
#define REG_AUDIO_LEFT_LINEOUT       2    // default value: 0x79
#define REG_AUDIO_RIGHT_LINEOUT      3    // default value: 0x79
#define REG_AUDIO_ANALOGUE_PATH      4    // default value: 0x0A
#define REG_AUDIO_DIGITAL_PATH       5    // default value: 0x08
#define REG_AUDIO_POWER_DOWN         6    // default value: 0x9F
#define REG_AUDIO_INTERFACE          7    // default value: 0x0A
#define REG_AUDIO_SAMPLING           8    // default value: 0x00
#define REG_AUDIO_ACTIVE             9    // default value: 0x00
#define REG_AUDIO_RESET             15


//REG_AUDIO_ANALOGUE_PATH
#define AANALOGUE_MICBOOST                    0x01
#define AANALOGUE_MUTEMIC                     0x02
#define AANALOGUE_INSEL                       0x04
#define AANALOGUE_BYPASS                      0x08
#define AANALOGUE_DACSEL                      0x10
#define AANALOGUE_SIDETONE                    0x20
#define AANALOGUE_SIDEATT_N6                  0x00
#define AANALOGUE_SIDEATT_N9                  0x40
#define AANALOGUE_SIDEATT_N12                 0x80
#define AANALOGUE_SIDEATT_N15                 0xC0

//REG_AUDIO_DIGITAL_PATH
#define ADIGITAL_ADCHPD                       0x01
#define ADIGITAL_DEEMP_DISABLE                0x00
#define ADIGITAL_DEEMP_32K                    0x02
#define ADIGITAL_DEEMP_44K1                   0x04
#define ADIGITAL_DEEMP_48K                    0x06
#define ADIGITAL_DACMU                        0x08
#define ADIGITAL_HPOR                         0x10

// audio - digital interface (REG_AUDIO_INTERFACE)
#define AIF_DSP                               0x03      
#define AIF_I2S                               0x02
#define AIF_MSB_LEFTJUST                      0x01
#define AIF_MSB_RIGHTJUST                     0x00
#define AIF_32BIT                             0x0C
#define AIF_24BIT                             0x08
#define AIF_20BIT                             0x04
#define AIF_16BIT                             0x00
#define AIF_LRP                               0x10
#define AIF_LRSWAP                            0x20
#define AIF_MS                                0x40
#define AIF_BCLKINV                           0x80

//REG_AUDIO_SAMPLING
#define ASAMPLING_USB                           0x01
#define ASAMPLING_BOSR                          0x02
#define ASAMPLING_SR_0000                       0x00

#define ASAMPLING_CLKIDIV2                      0x40
#define ASAMPLING_CLKODIV2                      0x80





#endif /*AUDIO_H_*/
