|
|
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: /* IOCD.h created by rick on Thu 08-Apr-1999 */
23:
24: /* =============================================================================
25: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
26: *
27: * IOCDDrive.h
28: *
29: * This class implements CD functionality, independent of
30: * the physical connection protocol (e.g. SCSI, ATA, USB).
31: *
32: * A protocol-specific provider implements the functionality using an appropriate
33: * protocol and commands.
34: */
35:
36: #ifndef _IOCDDRIVE_H
37: #define _IOCDDRIVE_H
38:
39: #include <IOKit/IOTypes.h>
40: #include <IOKit/storage/IOHDDrive.h>
41: #include "IOCDTypes.h"
42:
43: class IOCDAudioNub;
44: class IOCDMedia;
45: class IOCDDriveNub;
46:
47: class IOCDDrive : public IOHDDrive {
48:
49: OSDeclareDefaultStructors(IOCDDrive)
50:
51: public:
52:
53: /* Overrides of IORegistryEntry */
54:
55: virtual bool init(OSDictionary * properties);
56:
57: /* Overrides of IOHDDrive: */
58:
59: virtual IOReturn ejectMedia(void);
60: virtual const char * getDeviceTypeName(void);
61: virtual IOMedia * instantiateDesiredMediaObject(void);
62: virtual bool setProvider(IOService * provider);
63: virtual bool showStats(void);
64:
65: /* End of IOHDDrive overrides. */
66:
67: /* -------------------------------------------------*/
68: /* APIs implemented here, exported by IOCDMediaNub: */
69: /* -------------------------------------------------*/
70:
71: virtual IOReturn audioPause(bool pause);
72: virtual IOReturn audioScan(positioningType addressType,cdAddress address,
73: bool reverse);
74: virtual IOReturn readAudioData(positioningType addressType,cdAddress address,
75: UInt8 blockCount,UInt8 *buffer);
76: virtual IOReturn readAudioSubcodes(positioningType addressType,cdAddress address,
77: UInt8 blockCount,UInt8 *buffer);
78: virtual IOReturn readAudioWithQSubcode(positioningType addressType,cdAddress address,
79: UInt8 blockCount,UInt8 *buffer);
80: virtual IOReturn readAudioWithAllSubcodes(positioningType addressType,cdAddress address,
81: UInt8 blockCount,UInt8 *buffer);
82: virtual IOReturn readEntireTOC(struct macEntireToc *buffer);
83: virtual IOReturn readHeader(UInt32 blockAddress,struct headerInfo *buffer);
84: virtual IOReturn readISRC(UInt32 track,UInt8 *buffer,bool *found);
85: virtual IOReturn readLeadOutAddress(cdAddress *buffer);
86: virtual IOReturn readMCN(UInt8 *buffer,bool *found);
87: virtual IOReturn readQSubcodes(struct qSubcodeTocInfo *buffer,UInt32 bufSize);
88: virtual IOReturn readSessionInfo(struct sessionInfo *info);
89: virtual IOReturn readSubcodeBuffer(UInt8 *buffer,bool purge,UInt32 entryCount);
90: virtual IOReturn readTheQSubcode(struct qSubcode *buffer);
91: virtual IOReturn readTrackInfo(UInt32 startingTrack,
92: struct trackTypeInfo *buf,UInt32 bufSize);
93: virtual IOReturn readTrackLimits(UInt32 *first,UInt32 *last);
94:
95: /* end of IOCDMediaNub APIs */
96:
97: /* --------------------------------------------------------*/
98: /* APIs implemented here, exported by IOCDAudioNub: */
99: /* --------------------------------------------------------*/
100:
101: virtual IOReturn audioPlay(positioningType addressType,cdAddress address,audioPlayMode mode);
102: virtual IOReturn audioTrackSearch(positioningType addressType,cdAddress address,
103: bool startPlay,audioPlayMode mode);
104: virtual IOReturn getAudioStatus(struct audioStatus *status);
105: virtual IOReturn readAudioVolume(UInt8 *leftVolume,UInt8 *rightVolume);
106: virtual IOReturn setAudioStopAddress(positioningType addressType,cdAddress address);
107: virtual IOReturn setVolume(UInt8 leftVolume,UInt8 rightVolume);
108:
109: /* end of IOCDAudioNub APIs */
110:
111: /* API used by a CD partitioner: */
112:
113: virtual UInt32 getTrackBlocks(UInt32 track);
114: virtual UInt32 getTrackStartBlock(UInt32 track);
115: virtual bool trackExists(UInt32 track);
116: virtual bool trackIsAudio(UInt32 track);
117: virtual bool trackIsData(UInt32 track);
118:
119: protected:
120:
121: /* Overrides of IOHDDrive behavior. */
122:
123: /* When CD media is inserted, we want to create multiple nubs for the data and
124: * audio tracks, for sessions, and the entire media. We override the methods
125: * that manage nubs.
126: */
127: virtual IOReturn acceptNewMedia(void);
128: virtual IOReturn decommissionMedia(bool forcible);
129:
130: /* End of IOHDDrive overrides. */
131:
132: /* Internally used methods: */
133:
134: struct trackInfo {
135: UInt8 track; /* zero is invalid, thus this entry not in use */
136: UInt8 control;
137: bool isData;
138: UInt32 lba;
139: UInt32 msf;
140: UInt32 nblocks;
141: };
142:
143: virtual IOReturn cacheTocInfo(void);
144: virtual void dump(char *buf,int count);
145: virtual void setTrackInfoEntry(struct tocTrackDescriptor *d,struct trackInfo *t);
146:
147: /* ------- */
148:
149: /* We have to keep a pointer to a CD nub, because our base class's
150: * provider pointer only expects to point to a Hard Disk nub. Both
151: * pointers actually point at the same IOCDDriveNub object.
152: */
153: IOCDDriveNub * _CDprovider;
154:
155: IOCDAudioNub * _acNub;
156: IOCDMedia * _mediaNub;
157:
158:
159: /* We keep the TOC here because we'll always need it, so what the heck. */
160:
161: bool _tocInfoCached; /* true if toc info is valid */
162:
163: struct discInfo {
164: struct limits {
165: UInt32 first; /* number of first */
166: UInt32 last; /* and last */
167: } sessions;
168: struct limits tracks;
169: } _discInfo;
170:
171: /* There are possible "point" track entries for 0xa0..a2, 0xaa, 0xb0..b4, and 0xc0.
172: * To keep things simple, we just allow space for all of these possible track entries.
173: * Tracks need not start at 1, as long as they're between 1 and 99, and have contiguous
174: * numbers. The leadout track is always numbered 0xaa.
175: */
176: static const int kTrackEntries = 0xc0 + 1; /* 99 data/audio tracks + points, starting at 1 */
177:
178: struct trackInfo _trackInfo[kTrackEntries];
179: };
180: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.