|
|
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: /*! ! 24: * @header IOAudioBus ! 25: * Interface definition for the AudioBus audio Controller ! 26: * !! WARNING !! This is a temporary interface until the full bus abstraction has been worked out. ! 27: */ ! 28: ! 29: #ifndef _IOAUDIOBUS_H ! 30: #define _IOAUDIOBUS_H ! 31: ! 32: #include <IOKit/audio/IOAudio.h> ! 33: #include <IOKit/audio/IOAudioParts.h> ! 34: #include <IOKit/IORegistryEntry.h> ! 35: #include <IOKit/IOService.h> ! 36: #include <IOKit/IOUserClient.h> ! 37: #include <IOKit/assert.h> ! 38: #include <IOKit/audio/IOAudioController.h> ! 39: #include <IOKit/IOFilterInterruptEventSource.h> ! 40: ! 41: /*! ! 42: * @enum StreamDirection ! 43: * @constant kOutput ! 44: * @constant kInput ! 45: */ ! 46: enum StreamDirection ! 47: { ! 48: kOutput, ! 49: kInput ! 50: }; ! 51: ! 52: /*! ! 53: * @defined kInvalidStreamIndex ! 54: * @discussion Defines the invalid stream index value ! 55: */ ! 56: #define kInvalidStreamIndex -1 ! 57: ! 58: #ifdef __ppc__ ! 59: #include <IOKit/ppc/IODBDMA.h> ! 60: ! 61: /*! ! 62: * @class IOAudioBus ! 63: * @abstract This class handles all the DMA on PPC hardware ! 64: * @discussion FIXME: where it says __ppc__ it should be something like POWERRMAC ! 65: * since we can have PPC hardware with a different audio DMA implementation ! 66: */ ! 67: class IOAudioBus: public IOAudioController ! 68: { ! 69: OSDeclareDefaultStructors(IOAudioBus) ! 70: ! 71: /*! ! 72: * @struct StreamDMAInfo ! 73: * @abstract Maintains information relevant to DMA operations ! 74: * @field fSharedStatus ! 75: * @field fIOBaseDMA ! 76: * @field fCmds ! 77: * @field fDmaCmd ! 78: * @field fCmdSize ! 79: * @field fNeedsErase ! 80: * @field fIsInput ! 81: * @field fSampleRate ! 82: * @field streamProperty ! 83: */ ! 84: typedef struct StreamDMAInfo { ! 85: IOAudioStreamStatus * fSharedStatus; ! 86: volatile IODBDMAChannelRegisters * fIOBaseDMA; ! 87: IODBDMADescriptor * fCmds; ! 88: int16_t * fSampleBuffer; ! 89: u_int32_t fDmaCmd; ! 90: int fCmdSize; ! 91: int fNeedsErase; ! 92: bool fIsInput; ! 93: UInt32 fSampleRate; ! 94: char * streamProperty; ! 95: } StreamDMAInfo; ! 96: ! 97: UInt16 numDMAStreams; ! 98: StreamDMAInfo *ioAudioStreamsDMA; ! 99: int fBufMax; ! 100: int fBlockSize; ! 101: IOFilterInterruptEventSource * fTxInterruptSource; ! 102: IOFilterInterruptEventSource * fRxInterruptSource; ! 103: ! 104: public: ! 105: virtual bool init(OSDictionary *properties = 0); ! 106: virtual void free(); ! 107: ! 108: /*! ! 109: * @function AllocateStreams ! 110: * @abstract Creates n empty streams (also a method to free them) ! 111: * @param numberOfStreams ! 112: * @result bool ! 113: */ ! 114: virtual bool AllocateStreams(int numberOfStreams); ! 115: ! 116: /*! ! 117: * @function FreeStreams ! 118: * @abstract Deallocate audio streams ! 119: * @result bool ! 120: */ ! 121: virtual bool FreeStreams(); ! 122: ! 123: /*! ! 124: * @function DefineStream ! 125: * @abstract For each stream defines its properties ! 126: * @param index ! 127: * @param direction ! 128: * @param rate ! 129: * @param base ! 130: * @result bool ! 131: */ ! 132: virtual bool DefineStream(AudioStreamIndex index, int direction, UInt32 rate, IODBDMAChannelRegisters *base); ! 133: ! 134: /*! ! 135: * @function firstStreamAfter ! 136: * @abstract Returns the first stream in the given direction after the given index ! 137: * @discussion This is useful if we have to handle more than one stream for input and output ! 138: * @param inDirection ! 139: * @param afterIndex afterIndex is inclusive ! 140: * @result AudioStreamIndex returns kInvalidStreamIndex upon failure ! 141: */ ! 142: virtual AudioStreamIndex firstStreamAfter(int inDirection, AudioStreamIndex afterIndex); ! 143: ! 144: /*! ! 145: * @function getStreamProperties ! 146: * @param AudioStreamIndex ! 147: * @result OSDictionary The dictionary of properties ! 148: */ ! 149: virtual OSDictionary* getStreamProperties(AudioStreamIndex); ! 150: ! 151: /*! @function probeStreams */ ! 152: virtual int probeStreams(); ! 153: ! 154: /*! ! 155: * @function IOAudioStreamStatus ! 156: * @param AudioStreamIndex ! 157: * @result IOAudioStreamStatus ! 158: */ ! 159: virtual struct IOAudioStreamStatus* getSharedStatus(AudioStreamIndex); ! 160: ! 161: /*! ! 162: * @function getSampleBuffer ! 163: * @param AudioStreamIndex ! 164: * @result void* ! 165: */ ! 166: virtual void* getSampleBuffer(AudioStreamIndex); ! 167: ! 168: /*! ! 169: * @function startStream ! 170: * @param AudioStreamIndex ! 171: * @result IOAudioStreamStatus ! 172: */ ! 173: virtual struct IOAudioStreamStatus* startStream(AudioStreamIndex); ! 174: ! 175: /*! ! 176: * @function stopStream ! 177: * @param AudioStreamIndex ! 178: * @result void ! 179: */ ! 180: virtual void stopStream(AudioStreamIndex); ! 181: ! 182: /*! ! 183: * @function pauseStream ! 184: * @param AudioStreamIndex ! 185: * @result void ! 186: */ ! 187: virtual void pauseStream(AudioStreamIndex); ! 188: ! 189: /*! ! 190: * @function resumeStream ! 191: * @param AudioStreamIndex ! 192: * @result void ! 193: */ ! 194: virtual void resumeStream(AudioStreamIndex); ! 195: ! 196: /*! ! 197: * @function createAudioStream ! 198: * @param AudioStreamIndex ! 199: * @result IOAudioStream ! 200: */ ! 201: virtual IOAudioStream *createAudioStream(AudioStreamIndex index); ! 202: ! 203: protected: ! 204: /*! ! 205: * @var const kAudioDMAdeviceInt = 0 ! 206: * @discussion These constants define the one-to-one relationship between the transmit interrupt and a single output stream ! 207: * and the receive interrupt and a single input stream. ! 208: * It is up to the subclass to ensure that these relationships are properly used. ! 209: */ ! 210: static const int kAudioDMAdeviceInt; ! 211: ! 212: /*! @var const kAudioDMAtxInt = 1 */ ! 213: static const int kAudioDMAtxInt; ! 214: ! 215: /*! @var const kAudioDMAtxInt = 2 */ ! 216: static const int kAudioDMArxInt; ! 217: ! 218: /*! @var const kAudioDMAtxInt = 0 */ ! 219: static const AudioStreamIndex kAudioDMAOutputStream; ! 220: ! 221: /*! @var const kAudioDMAtxInt = 1 */ ! 222: static const AudioStreamIndex kAudioDMAInputStream; ! 223: ! 224: /*! ! 225: * @function startWorkLoop ! 226: * @result void ! 227: */ ! 228: virtual void startWorkLoop(); ! 229: ! 230: /*! ! 231: * @function registerInterrupts ! 232: * @result void ! 233: */ ! 234: virtual void registerInterrupts(); ! 235: ! 236: /*! ! 237: * @function filterInterrupt ! 238: * @param index ! 239: * @result bool ! 240: */ ! 241: virtual bool filterInterrupt(int index); ! 242: ! 243: /*! ! 244: * @function getStreamForInterrupt ! 245: * @param index ! 246: * @result AudioStreamIndex ! 247: */ ! 248: virtual AudioStreamIndex getStreamForInterrupt(int index); ! 249: ! 250: /*! ! 251: * @function AudioBusInterruptFilter ! 252: * @param owner ! 253: * @param source ! 254: * @result bool ! 255: */ ! 256: static bool AudioBusInterruptFilter(OSObject *owner, ! 257: IOFilterInterruptEventSource *source); ! 258: ! 259: /*! ! 260: * @function AudioBusInterruptHandler ! 261: * @param owner ! 262: * @param source ! 263: * @param count ! 264: * @result bool ! 265: */ ! 266: static void AudioBusInterruptHandler(OSObject *owner, ! 267: IOInterruptEventSource * source, ! 268: int count); ! 269: }; ! 270: ! 271: #else // ! ppc ! 272: ! 273: /*! ! 274: * @class IOAudioBus ! 275: * @abstract For non PPC hardware the calss still exists but the driver must implement all the DMA handling ! 276: */ ! 277: class IOAudioBus: public IOAudioController ! 278: { ! 279: OSDeclareDefaultStructors(IOAudioBus) ! 280: }; ! 281: ! 282: #endif //ppc ! 283: ! 284: #endif //_IOAUDIOBUS_H
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.