andrewm@0: /* andrewm@0: * I2c_Codec.h andrewm@0: * andrewm@0: * Handle writing the registers to the TLV320AIC310x andrewm@0: * series audio codecs, used on the BeagleBone Audio Cape. andrewm@0: * This code is designed to bypass the ALSA driver and andrewm@0: * configure the codec directly in a sensible way. It andrewm@0: * is complemented by code running on the PRU which uses andrewm@0: * the McASP serial port to transfer audio data. andrewm@0: * andrewm@0: * Created on: May 25, 2014 andrewm@0: * Author: Andrew McPherson andrewm@0: */ andrewm@0: andrewm@0: andrewm@0: #ifndef I2CCODEC_H_ andrewm@0: #define I2CCODEC_H_ andrewm@0: andrewm@0: #include "I2c.h" andrewm@0: andrewm@0: andrewm@0: class I2c_Codec : public I2c andrewm@0: { giuliomoro@134: short unsigned int pllJ; giuliomoro@134: short unsigned int pllD; giuliomoro@142: short unsigned int pllP; giuliomoro@142: short unsigned int pllR; giuliomoro@142: short unsigned int anotherField; andrewm@0: public: andrewm@0: int writeRegister(unsigned int reg, unsigned int value); andrewm@0: andrewm@0: int initCodec(); andrewm@0: int startAudio(int dual_rate); andrewm@0: int stopAudio(); andrewm@0: giuliomoro@96: int setPllJ(short unsigned int j); giuliomoro@96: int setPllD(unsigned int d); giuliomoro@142: int setPllP(short unsigned int p); giuliomoro@142: int setPllR(unsigned int r); giuliomoro@96: int setPllK(float k); giuliomoro@134: int setAudioSamplingRate(float newSamplingRate); giuliomoro@134: short unsigned int getPllJ(); giuliomoro@134: unsigned int getPllD(); giuliomoro@142: unsigned int getPllP(); giuliomoro@142: unsigned int getPllR(); giuliomoro@134: float getPllK(); giuliomoro@134: float getAudioSamplingRate(); andrewm@0: int setDACVolume(int halfDbSteps); andrewm@0: int writeDACVolumeRegisters(bool mute); andrewm@0: int setADCVolume(int halfDbSteps); andrewm@0: int writeADCVolumeRegisters(bool mute); andrewm@0: int setHPVolume(int halfDbSteps); andrewm@0: int writeHPVolumeRegisters(); andrewm@0: andrewm@0: int readI2C(); andrewm@0: andrewm@0: I2c_Codec(); andrewm@0: ~I2c_Codec(); andrewm@0: andrewm@0: private: andrewm@0: bool running; andrewm@0: int dacVolumeHalfDbs; andrewm@0: int adcVolumeHalfDbs; andrewm@0: int hpVolumeHalfDbs; andrewm@0: }; andrewm@0: andrewm@0: andrewm@0: #endif /* I2CCODEC_H_ */