Annotation of XNU/iokit/Drivers/audio/drvPPCDACA/PPCDACA.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  * Copyright (c) 1998 Apple Computer, Inc.  All rights reserved.
                     24:  *
                     25:  * Interface definition for the DAC 3550A audio Controller
                     26:  *
                     27:  * HISTORY
                     28:  *
                     29:  */
                     30: 
                     31: #ifndef _PPCDACA_H
                     32: #define _PPCDACA_H
                     33: 
                     34: #include <IOKit/audio/IOAudioBus.h>
                     35: 
                     36: #include "PPCI2CInterface.h"
                     37: 
                     38: // Uncomment the following line to log the driver activity
                     39: //#define DEBUGMODE
                     40: 
                     41: // If this is uncommented we increase the number of checkpoints
                     42: // for data consistency:
                     43: //#define BEPARANOID
                     44: 
                     45: struct IODBDMAChannelRegisters;
                     46: struct IODBDMADescriptor;
                     47: 
                     48: class PPCDACA : public IOAudioBus
                     49: {
                     50:     OSDeclareDefaultStructors(PPCDACA)
                     51:     
                     52: private:
                     53:     // Controls for sound source and destination
                     54:     enum soundControls {
                     55:         kSpeakerMute = 0,
                     56:         kSpeakerVolLeft = 1,
                     57:         kSpeakerVolRight = 2,
                     58:         kHeadphonesMute = 3,
                     59:         kHeadphonesVolLeft = 4,
                     60:         kHeadphonesVolRight = 5,
                     61:         kModemMute = 6,
                     62:         kCDMute = 7,
                     63:         kMixerInVolLeft = 8,
                     64:         kMixerInVolRight = 9,
                     65:         kPassThruVolLeft = 10,
                     66:         kPassThruVolRight = 11,
                     67:         kPassThruMute = 12,
                     68:         kNumControls
                     69:     };
                     70: 
                     71:     // There is a set of components that depend on each other (e.g. speaker
                     72:     // and headphones) the following map helps to always retrive the right
                     73:     // component.
                     74:     enum standardInputComponents {
                     75:         kCD = 0,
                     76:         kModem = 1,
                     77:         kUndefinedInput
                     78:     };
                     79: 
                     80:     enum standardOutputComponents {
                     81:         kSpeaker = 0,
                     82:         kHeadphones = 1,
                     83:         kUndefinedOutput
                     84:     };
                     85: 
                     86:     // Characteristic constants:
                     87:     typedef enum TicksPerFrame {
                     88:         k64TicksPerFrame               = 64,                   // 64 ticks per frame
                     89:         k32TicksPerFrame               = 32                    // 32 ticks per frame
                     90:     } TicksPerFrame;
                     91:     
                     92:     typedef enum ClockSource {
                     93:             kClock49MHz                                = 49152000,             // 49 MHz clock source
                     94:             kClock45MHz                                = 45158400,             // 45 MHz clock source
                     95:             kClock18MHz                                = 18432000               // 18 MHz clock source
                     96:     } ClockSource;
                     97: 
                     98:     // Sound Formats:
                     99:     // FIXME: these values are "interpreted" and mirrored in specific chip values
                    100:     // so wouldn't be better to have them in some parent class?
                    101:     typedef enum SoundFormat {
                    102:         kSndIOFormatI2SSony,
                    103:         kSndIOFormatI2S64x,
                    104:         kSndIOFormatI2S32x,
                    105: 
                    106:         // This says "we never decided for a sound format before"
                    107:         kSndIOFormatUnknown
                    108:     } SoundFormat;
                    109: 
                    110:     // *************************************
                    111:     // * DACA Mirror Regs  Member Function *
                    112:     // *************************************
                    113:     UInt8  sampleRateReg;
                    114:     UInt16 analogVolumeReg;
                    115:     UInt8  configurationReg;
                    116: 
                    117:     // This is to handle the volumes for the two output
                    118:     UInt16 internalSpeakerVolume;
                    119:     UInt16 internalHeadphonesVolume;
                    120: 
                    121:     // These handle the mute states:
                    122:     bool internalSpeakerMuted;
                    123:     bool internalHeadphonesMuted;
                    124: 
                    125:     // ****************************
                    126:     // * Generic  Member Function *
                    127:     // ****************************
                    128:     UInt32 ReadWordLittleEndian(void *address,UInt32 offset);
                    129:     void WriteWordLittleEndian(void *address, UInt32 offset, UInt32 value);
                    130: 
                    131:     // *********************************
                    132:     // * I 2 S  DATA & Member Function *
                    133:     // *********************************
                    134:     void *soundConfigSpace;        // address of sound config space
                    135:     void *ioBaseAddress;           // base address of our I/O controller
                    136:     void *ioClockBaseAddress;     // base address for the clock
                    137:     void *ioStatusRegister_GPIO12; // the register with the input detection
                    138: 
                    139:     // Recalls which i2s interface we are attached to:
                    140:     UInt8 i2SInterfaceNumber;
                    141:     
                    142:     // Access to all the I2S registers:
                    143:     // -------------------------------
                    144:     UInt32 I2SGetIntCtlReg();
                    145:     void   I2SSetIntCtlReg(UInt32 value);
                    146:     UInt32 I2SGetSerialFormatReg();
                    147:     void   I2SSetSerialFormatReg(UInt32 value);
                    148:     UInt32 I2SGetCodecMsgOutReg();
                    149:     void   I2SSetCodecMsgOutReg(UInt32 value);
                    150:     UInt32 I2SGetCodecMsgInReg();
                    151:     void   I2SSetCodecMsgInReg(UInt32 value);
                    152:     UInt32 I2SGetFrameCountReg();
                    153:     void   I2SSetFrameCountReg(UInt32 value);
                    154:     UInt32 I2SGetFrameMatchReg();
                    155:     void   I2SSetFrameMatchReg(UInt32 value);
                    156:     UInt32 I2SGetDataWordSizesReg();
                    157:     void   I2SSetDataWordSizesReg(UInt32 value);
                    158:     UInt32 I2SGetPeakLevelSelReg();
                    159:     void   I2SSetPeakLevelSelReg(UInt32 value);
                    160:     UInt32 I2SGetPeakLevelIn0Reg();
                    161:     void   I2SSetPeakLevelIn0Reg(UInt32 value);
                    162:     UInt32 I2SGetPeakLevelIn1Reg();
                    163:     void   I2SSetPeakLevelIn1Reg(UInt32 value);
                    164:     UInt32 I2SCounterReg();
                    165: 
                    166:     // starts and stops the clock count:
                    167:     void   KLSetRegister(void *klRegister, UInt32 value);
                    168:     UInt32   KLGetRegister(void *klRegister);
                    169:     bool clockRun(bool start);
                    170: 
                    171:     // Enables and disables the interrupts:
                    172:     bool enableInterrupts();
                    173:     bool disableInterrupts();
                    174:         
                    175:     // Define the sound parameters for the adac:
                    176:     bool setSampleParameters(UInt32 sampleRate, UInt32 mclkToFsRatio);
                    177:     bool setDACAVolume(UInt16 volume, bool isLeft);
                    178:     void setSerialFormatRegister(ClockSource clockSource, UInt32 mclkDivisor, UInt32 sclkDivisor, SoundFormat serialFormat);
                    179: 
                    180:     // *********************************
                    181:     // * I 2 C  DATA & Member Function *
                    182:     // *********************************
                    183: 
                    184:     // This provides access to the DACA registers:
                    185:     PPCI2CInterface *interface;
                    186: 
                    187:     // Attaches to the i2c interface:
                    188:     bool findAndAttachI2C(IOService *provider);
                    189:     bool detachFromI2C(IOService *provider);
                    190: 
                    191:     // sets the sample rate:
                    192:     bool setDACASampleRate(UInt);
                    193:     
                    194:     // Access o the i2c registers:
                    195:     bool writeRegisterBits(UInt8 subAddress, UInt32 bitMaskOn, UInt32 bitMaskOff);
                    196:     
                    197:     // for each line (in input and output) we have an audio component:
                    198:     typedef IOAudioComponentImpl *IOAudioComponentImplPtr;
                    199:     UInt16                             numOutputComponents;
                    200:     IOAudioComponentImplPtr            *fOutputComponents;
                    201: 
                    202:     // Remember the provider
                    203:     IORegistryEntry *sound;
                    204: 
                    205:     // holds the current frame rate settings:
                    206:     ClockSource dacaClockSource;
                    207:     UInt32      dacaMclkDivisor;
                    208:     UInt32      dacaSclkDivisor;
                    209:     SoundFormat dacaSerialFormat;
                    210: 
                    211:     // Remebers the last value of the status register
                    212:     UInt8      lastStatus;
                    213:     
                    214: protected:
                    215:     // Discovers if this is a DAC-3550 compatible device:
                    216:     bool implementsDACA(IORegistryEntry*);
                    217: 
                    218:     // Finds the number of DMA channels and their direction:
                    219:     int numOfDMAChannels();
                    220: 
                    221:     // finds the number of components for the
                    222:     // input and output lines:
                    223:     int numberOfOutputComponents();
                    224:     int numberOfInputComponents();
                    225: 
                    226:     // returns the frame rate or the input and output
                    227:     // channels. Possibly reading them from the registry
                    228:     UInt32 frameRate(UInt32);
                    229: 
                    230:     // Finds the i2c port to use for the audio chip
                    231:     UInt32 getI2CPort();
                    232:     
                    233:     // Acts on changes of the status register:
                    234:     void checkStatusRegister();
                    235:     bool inputComponentStatus(int);
                    236:     bool outputComponentStatus(int);
                    237: 
                    238:     // this handles the setup of the DAC-3550 chip for each kind of
                    239:     // hosting hardware.
                    240:     bool dependentSetup();
                    241: 
                    242:     // Returns true if some sense line changed in the
                    243:     // status register since the last check:
                    244:     bool statusChanged();
                    245: 
                    246:     // A mute function for each supported mute line:
                    247:     void muteInternalSpeaker(bool);
                    248:     void muteHeadphones(bool);
                    249:     void muteCDLine(bool);
                    250: 
                    251:     // Sets the modem as input source:
                    252:     void setModemInput(bool);
                    253: 
                    254:     // sets the volume for the output lines:
                    255:     void volumeInternalSpeakerLeft(int);
                    256:     void volumeInternalSpeakerRight(int);
                    257:         
                    258:     void volumeHeadphonesLeft(int);
                    259:     void volumeHeadphonesRight(int);
                    260:     
                    261:     void volumeCDLineLeft(int);
                    262:     void volumeCDLineRight(int);
                    263:        
                    264:     // Sets the gain for the input line:
                    265:     void volumeMixerInLeft(int);
                    266:     void volumeMixerInRight(int);
                    267:     
                    268:     // A sense function for each "jacked" input:
                    269:     bool headphonesInserted();
                    270: 
                    271:     // they return the strings for the component dictionaries
                    272:     // for each kind of component
                    273:     char* componentDictionarySpeaker();
                    274:     char* componentDictionaryHeadphones();
                    275:     char* componentDictionaryModem();
                    276:     char* componentDictionaryCD();
                    277:     char* componentDictionaryMixerIn();
                    278:     char* componentDictionaryMixerOut();
                    279:     char* componentDictionaryPassThru();
                    280: 
                    281: public:
                    282:     virtual bool init(OSDictionary *properties = 0);
                    283:     virtual void free();
                    284:     virtual IOService* probe(IOService *provider, SInt32*);
                    285:     virtual bool start(IOService*);
                    286:     virtual void stop(IOService*);
                    287:     virtual void DoClockTick(IOTimerEventSource*);
                    288:     virtual void calculateTickInterval(AbsoluteTime *tickInterval);
                    289:     
                    290:     // These are all the functions we need to override:
                    291:     virtual IOReturn SetControl(UInt16, int);
                    292:     virtual void CreateAudioTopology(class IOCommandQueue *);
                    293: };
                    294: 
                    295: #endif /* !_PPCDACA_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.