I2STransportInterface.h [plain text]
#include <IOKit/IOService.h>
#include "PlatformInterface.h"
#include "TransportInterface.h"
#ifndef __I2S_TRANSPORT_INTERFACE
#define __I2S_TRANSPORT_INTERFACE
typedef enum ClockSource
{
kClock49MHz = 49152000, kClock45MHz = 45158400, kClock18MHz = 18432000 } ClockSource;
typedef enum ExternalSampleRate {
kSampleRate_11Khz_LowerLimt = 1663,
kSampleRate_11Khz_UpperLimt = 1682,
kSampleRate_16Khz_LowerLimt = 1146,
kSampleRate_16Khz_UpperLimt = 1159,
kSampleRate_22Khz_LowerLimt = 831,
kSampleRate_22Khz_UpperLimt = 842,
kSampleRate_24Khz_LowerLimt = 764,
kSampleRate_24Khz_UpperLimt = 773,
kSampleRate_32Khz_LowerLimt = 574,
kSampleRate_32Khz_UpperLimt = 580,
kSampleRate_44Khz_LowerLimt = 415,
kSampleRate_44Khz_UpperLimt = 419,
kSampleRate_48Khz_LowerLimt = 382,
kSampleRate_48Khz_UpperLimt = 386,
kSampleRate_64Khz_LowerLimt = 286,
kSampleRate_64Khz_UpperLimt = 291,
kSampleRate_88Khz_LowerLimt = 207,
kSampleRate_88Khz_UpperLimt = 210,
kSampleRate_96Khz_LowerLimt = 190,
kSampleRate_96Khz_UpperLimt = 194,
kSampleRate_176Khz_LowerLimt = 103,
kSampleRate_176Khz_UpperLimt = 107,
kSampleRate_192Khz_LowerLimt = 94,
kSampleRate_192Khz_UpperLimt = 98
} ExternalSampleRate;
typedef enum SoundFormat
{
kSndIOFormatI2SSony,
kSndIOFormatI2S64x,
kSndIOFormatI2S32x,
kSndIOFormatUnknown
} SoundFormat;
typedef enum TicksPerFrame
{
k64TicksPerFrame = 64, k32TicksPerFrame = 32 } TicksPerFrame;
enum {
kFrameCountEnableShift = 31, kFrameCountPendingShift = 30, kMsgFlagEnableShift = 29, kMsgFlagPendingShift = 28, kNewPeakEnableShift = 27, kNewPeakPendingShift = 26, kClocksStoppedEnableShift = 25, kClocksStoppedPendingShift = 24, kExtSyncErrorEnableShift = 23, kExtSyncErrorPendingShift = 22, kExtSyncOKEnableShift = 21, kExtSyncOKPendingShift = 20, kNewSampleRateEnableShift = 19, kNewSampleRatePendingShift = 18, kStatusFlagEnableShift = 17, kStatusFlagPendingShift = 16 };
enum {
kClockSource18MHz = 0, kClockSource45MHz = 1, kClockSource49MHz = 2, kClockSourceShift = 30, kMClkDivisorShift = 24, kSClkDivisorShift = 20, kBClkMasterShift = 19, kSClkMaster = 1, kSClkSlave = 0, kSerialFormatShift = 16, kSerialFormatSony = 0, kSerialFormat64x = 1, kSerialFormat32x = 2, kSerialFormatDAV = 4, kSerialFormatSiliLabs = 5, kExtSampleFreqIntShift = 12, };
enum {
kNumChannelsInShift = 24, kDataInSizeShift = 16, kDataIn16 = 0, kDataIn24 = 3, kNumChannelsOutShift = 8, kDataOutSizeShift = 0, kDataOut16 = 0, kDataOut24 = 3, kI2sStereoChannels = 2, kI2sMonoChannels = 1 };
enum {
kNewPeakInShift = 31, kNewPeakInMask = (1<<31), kHoldPeakInShift = 30, kHoldPeakInMask = (1<<30), kHoldPeakInEnable = (0<<30), kHoldPeakInDisable = (1<<30), kPeakValueMask = 0x00FFFFFF };
class I2STransportInterface : public TransportInterface {
OSDeclareDefaultStructors ( I2STransportInterface );
public:
virtual bool init (PlatformInterface * inPlatformInterface);
virtual void free ( void );
virtual IOReturn transportSetSampleRate ( UInt32 sampleRate );
virtual IOReturn transportSetSampleWidth ( UInt32 sampleWidth, UInt32 dmaWidth );
virtual IOReturn performTransportSleep ( void );
virtual IOReturn performTransportWake ( void );
virtual IOReturn transportBreakClockSelect ( UInt32 clockSource );
virtual IOReturn transportMakeClockSelect ( UInt32 clockSource );
virtual bool transportCanClockSelect ( UInt32 clockSource ) {return false;}
virtual UInt32 transportGetSampleRate ( void );
IOReturn transportSetPeakLevel ( UInt32 channelTarget, UInt32 levelMeterValue );
UInt32 transportGetPeakLevel ( UInt32 channelTarget );
virtual IOReturn getTransportInterfaceState ( TransportStateStructPtr outState );
virtual IOReturn setTransportInterfaceState ( TransportStateStructPtr inState );
private:
UInt32 mMclkMultiplier;
UInt32 mSclkMultiplier;
UInt32 mMClkFrequency;
UInt32 mSClkFrequency;
UInt32 mClockSourceFrequency;
UInt32 mMClkDivisor; UInt32 mSClkDivisor; UInt32 mMClkDivider; UInt32 mSClkDivider; UInt32 mSerialFormat; UInt32 mDataWordSize; I2SClockFrequency mClockSelector;
Boolean mHave18MHzClock;
Boolean mHave45MHzClock;
Boolean mHave49MHzClock;
IOReturn requestClockSources ();
IOReturn releaseClockSources ();
IOReturn calculateSerialFormatRegisterValue ( UInt32 sampleRate );
void waitForClocksStopped ( void );
};
#endif