#ifndef _AUDIOI2SCONTROL_H
#define _AUDIOI2SCONTROL_H
#include "AudioHardwareCommon.h"
#include "AudioHardwareUtilities.h"
#include "AppleOnboardAudio.h"
#ifdef DEBUGMODE
#define INLINE
#else
#define INLINE inline
#endif
typedef enum SoundFormat
{
kSndIOFormatI2SSony,
kSndIOFormatI2S64x,
kSndIOFormatI2S32x,
kSndIOFormatUnknown
} SoundFormat;
typedef enum TicksPerFrame
{
k64TicksPerFrame = 64, k32TicksPerFrame = 32 } TicksPerFrame;
typedef enum ClockSource
{
kClock49MHz = 49152000, kClock45MHz = 45158400, kClock18MHz = 18432000 } ClockSource;
typedef struct _s_AudioI2SInfo
{
SoundFormat i2sSerialFormat;
IOMemoryMap *map ;
} AudioI2SInfo ;
class AudioI2SControl : public OSObject
{
OSDeclareDefaultStructors(AudioI2SControl);
private:
ClockSource dacaClockSource;
UInt32 dacaMclkDivisor;
UInt32 dacaSclkDivisor;
SoundFormat dacaSerialFormat;
bool setSampleParameters( UInt32 sampleRate, UInt32 mclkToFsRatio) ;
void setSerialFormatRegister( ClockSource clockSource, UInt32 mclkDivisor, UInt32 sclkDivisor, SoundFormat serialFormat) ;
bool dependentSetup(void) ;
UInt32 ReadWordLittleEndian(void *address,UInt32 offset);
void WriteWordLittleEndian(void *address, UInt32 offset, UInt32 value);
void *soundConfigSpace; void *ioBaseAddress; void *ioClockBaseAddress; void *ioStatusRegister_GPIO12;
UInt8 i2SInterfaceNumber;
public:
UInt32 I2SGetIntCtlReg();
void I2SSetIntCtlReg(UInt32 value);
UInt32 I2SGetSerialFormatReg();
void I2SSetSerialFormatReg(UInt32 value);
UInt32 I2SGetCodecMsgOutReg();
void I2SSetCodecMsgOutReg(UInt32 value);
UInt32 I2SGetCodecMsgInReg();
void I2SSetCodecMsgInReg(UInt32 value);
UInt32 I2SGetFrameCountReg();
void I2SSetFrameCountReg(UInt32 value);
UInt32 I2SGetFrameMatchReg();
void I2SSetFrameMatchReg(UInt32 value);
UInt32 I2SGetDataWordSizesReg();
void I2SSetDataWordSizesReg(UInt32 value);
UInt32 I2SGetPeakLevelSelReg();
void I2SSetPeakLevelSelReg(UInt32 value);
UInt32 I2SGetPeakLevelIn0Reg();
void I2SSetPeakLevelIn0Reg(UInt32 value);
UInt32 I2SGetPeakLevelIn1Reg();
void I2SSetPeakLevelIn1Reg(UInt32 value);
UInt32 I2SCounterReg();
void KLSetRegister(void *klRegister, UInt32 value);
UInt32 KLGetRegister(void *klRegister);
static AudioI2SControl *create(AudioI2SInfo *theInfo) ;
inline void *getIOStatusRegister_GPIO12(void) { return (ioStatusRegister_GPIO12); } ;
protected:
bool init(AudioI2SInfo *theInfo) ;
void free(void) ;
bool clockRun(bool start) ;
UInt32 frameRate(UInt32 index) ;
} ;
#endif