]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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 | * HISTORY | |
26 | * 30 Nov 98 sdouglas start cpp, from previous versions. | |
27 | */ | |
28 | ||
29 | #ifndef _IOKIT_IOFRAMEBUFFER_H | |
30 | #define _IOKIT_IOFRAMEBUFFER_H | |
31 | ||
32 | #include <IOKit/IOService.h> | |
33 | #include <IOKit/graphics/IOGraphicsDevice.h> | |
34 | #include <IOKit/graphics/IOFramebufferShared.h> | |
35 | #include <IOKit/IOLib.h> | |
36 | ||
37 | class IOFramebuffer; | |
38 | class IOBufferMemoryDescriptor; | |
39 | ||
40 | typedef void (*CursorBlitProc)( | |
41 | IOFramebuffer * inst, | |
42 | void * shmem, | |
43 | volatile unsigned char *vramPtr, | |
44 | unsigned int cursStart, | |
45 | unsigned int vramRow, | |
46 | unsigned int cursRow, | |
47 | int width, | |
48 | int height ); | |
49 | ||
50 | typedef void (*CursorRemoveProc)( | |
51 | IOFramebuffer * inst, | |
52 | void * shmem, | |
53 | volatile unsigned char *vramPtr, | |
54 | unsigned int vramRow, | |
55 | int width, | |
56 | int height ); | |
57 | ||
58 | enum { | |
59 | kTransparentEncoding = 0, | |
60 | kInvertingEncoding | |
61 | }; | |
62 | ||
63 | enum { | |
64 | kTransparentEncodingShift = (kTransparentEncoding << 1), | |
65 | kTransparentEncodedPixel = (0x01 << kTransparentEncodingShift), | |
66 | ||
67 | kInvertingEncodingShift = (kInvertingEncoding << 1), | |
68 | kInvertingEncodedPixel = (0x01 << kInvertingEncodingShift), | |
69 | }; | |
70 | ||
71 | enum { | |
72 | kHardwareCursorDescriptorMajorVersion = 0x0001, | |
73 | kHardwareCursorDescriptorMinorVersion = 0x0000 | |
74 | }; | |
75 | ||
76 | struct IOHardwareCursorDescriptor { | |
77 | UInt16 majorVersion; | |
78 | UInt16 minorVersion; | |
79 | UInt32 height; | |
80 | UInt32 width; | |
81 | UInt32 bitDepth; | |
82 | UInt32 maskBitDepth; | |
83 | UInt32 numColors; | |
84 | UInt32 * colorEncodings; | |
85 | UInt32 flags; | |
86 | UInt32 supportedSpecialEncodings; | |
87 | UInt32 specialEncodings[16]; | |
88 | }; | |
89 | typedef struct IOHardwareCursorDescriptor IOHardwareCursorDescriptor; | |
90 | ||
91 | enum { | |
92 | kHardwareCursorInfoMajorVersion = 0x0001, | |
93 | kHardwareCursorInfoMinorVersion = 0x0000 | |
94 | }; | |
95 | ||
96 | struct IOHardwareCursorInfo { | |
97 | UInt16 majorVersion; | |
98 | UInt16 minorVersion; | |
99 | UInt32 cursorHeight; | |
100 | UInt32 cursorWidth; | |
101 | // nil or big enough for hardware's max colors | |
102 | IOColorEntry * colorMap; | |
103 | UInt8 * hardwareCursorData; | |
104 | UInt32 reserved[6]; | |
105 | }; | |
106 | typedef struct IOHardwareCursorInfo IOHardwareCursorInfo; | |
107 | ||
108 | // clock & data values | |
109 | enum { | |
110 | kIODDCLow = 0, | |
111 | kIODDCHigh = 1, | |
112 | kIODDCTristate = 2 | |
113 | }; | |
114 | // ddcBlockType constants | |
115 | enum { | |
116 | // EDID block type. | |
117 | kIODDCBlockTypeEDID = 0 | |
118 | }; | |
119 | ||
120 | // ddcFlags constants | |
121 | enum { | |
122 | // Force a new read of the EDID. | |
123 | kIODDCForceRead = 0x00000001, | |
124 | }; | |
125 | ||
126 | enum { | |
127 | kDisabledInterruptState = 0, | |
128 | kEnabledInterruptState = 1 | |
129 | }; | |
130 | ||
131 | typedef void (*IOFBInterruptProc)( OSObject * target, void * ref ); | |
132 | ||
133 | ||
134 | typedef IOReturn (*IOFramebufferNotificationHandler) | |
135 | (OSObject * self, void * ref, | |
136 | IOFramebuffer * framebuffer, IOIndex event, | |
137 | void * info); | |
138 | ||
139 | // IOFramebufferNotificationHandler events | |
140 | enum { | |
141 | kIOFBNotifyDisplayModeWillChange = 1, | |
142 | kIOFBNotifyDisplayModeDidChange, | |
143 | kIOFBNotifyWillSleep, | |
144 | kIOFBNotifyDidWake, | |
145 | }; | |
146 | ||
147 | ||
148 | struct StdFBShmem_t; | |
149 | class IOFramebufferUserClient; | |
150 | ||
151 | class IOFramebuffer : public IOGraphicsDevice | |
152 | { | |
153 | friend class IOFramebufferUserClient; | |
154 | friend class IOFramebufferSharedUserClient; | |
155 | friend class IOGraphicsEngineClient; | |
156 | ||
157 | OSDeclareDefaultStructors(IOFramebuffer) | |
158 | ||
159 | protected: | |
160 | /*! @struct ExpansionData | |
161 | @discussion This structure will be used to expand the capablilties of this class in the future. | |
162 | */ | |
163 | struct ExpansionData { }; | |
164 | ||
165 | /*! @var reserved | |
166 | Reserved for future use. (Internal use only) */ | |
167 | ExpansionData * reserved; | |
168 | ||
169 | private: | |
170 | ||
171 | protected: | |
172 | StdFBShmem_t * priv; | |
173 | int shmemClientVersion; | |
174 | IOBufferMemoryDescriptor * sharedCursor; | |
175 | ||
176 | union { | |
177 | struct { | |
178 | /* Mapping tables used in cursor drawing to 5-5-5 displays. */ | |
179 | unsigned char * _bm34To35SampleTable; | |
180 | unsigned char * _bm35To34SampleTable; | |
181 | /* Mapping tables used in cursor drawing to 8-bit RGB displays. */ | |
182 | unsigned int * _bm256To38SampleTable; | |
183 | unsigned char * _bm38To256SampleTable; | |
184 | } t; | |
185 | UInt8 * tables[ 4 ]; | |
186 | } colorConvert; | |
187 | ||
188 | /* cursor blitting vars */ | |
189 | CursorBlitProc cursorBlitProc; | |
190 | CursorRemoveProc cursorRemoveProc; | |
191 | ||
192 | IOGSize maxCursorSize; | |
193 | volatile unsigned char * cursorImages[ kIOFBNumCursorFrames ]; | |
194 | volatile unsigned char * cursorMasks[ kIOFBNumCursorFrames ]; | |
195 | volatile unsigned char * cursorSave; | |
196 | unsigned int white; | |
197 | ||
198 | Point nextCursorLoc; | |
199 | int nextCursorFrame; | |
200 | void * vblInterrupt; | |
201 | semaphore_t vblSemaphore; | |
202 | ||
203 | /* memory ranges */ | |
204 | volatile unsigned char * frameBuffer; | |
205 | unsigned int totalWidth; | |
206 | unsigned int rowBytes; | |
207 | unsigned int bytesPerPixel; | |
208 | ||
209 | IOMemoryMap * vramMap; | |
210 | IOByteCount vramMapOffset; | |
211 | OSArray * userAccessRanges; | |
212 | OSArray * engineAccessRanges; | |
213 | IOBufferMemoryDescriptor * engineContext; | |
214 | OSSet * fbNotifications; | |
215 | ||
216 | class IOFramebufferUserClient * serverConnect; | |
217 | class IOFramebufferSharedUserClient * sharedConnect; | |
218 | ||
219 | bool opened; | |
220 | bool closed; | |
221 | bool clutValid; | |
222 | bool currentMono; | |
223 | bool needCursorService; | |
224 | bool haveVBLService; | |
225 | bool haveHWCursor; | |
226 | bool hwCursorLoaded; | |
227 | ||
228 | void * pmRef; | |
229 | ||
230 | /* Reserved for future expansion. */ | |
231 | int _IOFramebuffer_reserved[7]; | |
232 | ||
233 | private: | |
234 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 0); | |
235 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 1); | |
236 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 2); | |
237 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 3); | |
238 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 4); | |
239 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 5); | |
240 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 6); | |
241 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 7); | |
242 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 8); | |
243 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 9); | |
244 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 10); | |
245 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 11); | |
246 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 12); | |
247 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 13); | |
248 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 14); | |
249 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 15); | |
250 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 16); | |
251 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 17); | |
252 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 18); | |
253 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 19); | |
254 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 20); | |
255 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 21); | |
256 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 22); | |
257 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 23); | |
258 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 24); | |
259 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 25); | |
260 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 26); | |
261 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 27); | |
262 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 28); | |
263 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 29); | |
264 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 30); | |
265 | OSMetaClassDeclareReservedUnused(IOFramebuffer, 31); | |
266 | ||
267 | ||
268 | public: | |
269 | static void initialize(); | |
270 | ||
271 | virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService* ); | |
272 | virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService* ); | |
273 | virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService * device); | |
274 | virtual IOReturn newUserClient( task_t owningTask, | |
275 | void * security_id, | |
276 | UInt32 type, | |
277 | IOUserClient ** handler ); | |
278 | ||
279 | ||
280 | virtual void hideCursor( void ); | |
281 | virtual void showCursor( Point * cursorLoc, int frame ); | |
282 | virtual void moveCursor( Point * cursorLoc, int frame ); | |
283 | // virtual | |
284 | void resetCursor( void ); | |
285 | ||
286 | virtual void getVBLTime( AbsoluteTime * time, AbsoluteTime * delta ); | |
287 | ||
288 | virtual void getBoundingRect ( Bounds ** bounds ); | |
289 | ||
290 | virtual bool start( IOService * provider ); | |
291 | ||
292 | virtual IOReturn open( void ); | |
293 | ||
294 | virtual void close( void ); | |
295 | ||
296 | virtual bool isConsoleDevice( void ); | |
297 | ||
298 | virtual IOReturn setupForCurrentConfig( void ); | |
299 | ||
300 | virtual bool serializeInfo( OSSerialize * s ); | |
301 | virtual bool setNumber( OSDictionary * dict, const char * key, | |
302 | UInt32 number ); | |
303 | ||
304 | IONotifier * addFramebufferNotification( | |
305 | IOFramebufferNotificationHandler handler, | |
306 | OSObject * self, void * ref); | |
307 | ||
308 | virtual IODeviceMemory * getApertureRange( IOPixelAperture aperture ) = 0; | |
309 | virtual IODeviceMemory * getVRAMRange( void ); | |
310 | ||
311 | protected: | |
312 | ||
313 | IOReturn deliverFramebufferNotification( | |
314 | IOIndex event, void * info = 0 ); | |
315 | ||
316 | #ifdef IOFRAMEBUFFER_PRIVATE | |
317 | #include <IOKit/graphics/IOFramebufferPrivate.h> | |
318 | #endif | |
319 | ||
320 | public: | |
321 | ||
322 | virtual IOReturn enableController( void ); | |
323 | ||
324 | // List of pixel formats supported, null separated, | |
325 | // doubly null terminated. | |
326 | virtual const char * getPixelFormats( void ) = 0; | |
327 | ||
328 | // Array of supported display modes | |
329 | virtual IOItemCount getDisplayModeCount( void ) = 0; | |
330 | virtual IOReturn getDisplayModes( IODisplayModeID * allDisplayModes ) = 0; | |
331 | ||
332 | // Info about a display mode | |
333 | virtual IOReturn getInformationForDisplayMode( IODisplayModeID displayMode, | |
334 | IODisplayModeInformation * info ) = 0; | |
335 | ||
336 | // Mask of pixel formats available in mode and depth | |
337 | virtual UInt64 getPixelFormatsForDisplayMode( IODisplayModeID displayMode, | |
338 | IOIndex depth ) = 0; | |
339 | ||
340 | virtual IOReturn getPixelInformation( | |
341 | IODisplayModeID displayMode, IOIndex depth, | |
342 | IOPixelAperture aperture, IOPixelInformation * pixelInfo ) = 0; | |
343 | ||
344 | // Framebuffer info | |
345 | ||
346 | // Current display mode and depth | |
347 | virtual IOReturn getCurrentDisplayMode( IODisplayModeID * displayMode, | |
348 | IOIndex * depth ) = 0; | |
349 | ||
350 | // Set display mode and depth | |
351 | virtual IOReturn setDisplayMode( IODisplayModeID displayMode, | |
352 | IOIndex depth ); | |
353 | ||
354 | // For pages | |
355 | virtual IOReturn setApertureEnable( IOPixelAperture aperture, | |
356 | IOOptionBits enable ); | |
357 | ||
358 | // Display mode and depth for startup | |
359 | virtual IOReturn setStartupDisplayMode( IODisplayModeID displayMode, | |
360 | IOIndex depth ); | |
361 | virtual IOReturn getStartupDisplayMode( IODisplayModeID * displayMode, | |
362 | IOIndex * depth ); | |
363 | ||
364 | //// CLUTs | |
365 | ||
366 | virtual IOReturn setCLUTWithEntries( IOColorEntry * colors, UInt32 index, | |
367 | UInt32 numEntries, IOOptionBits options ); | |
368 | ||
369 | //// Gamma | |
370 | ||
371 | virtual IOReturn setGammaTable( UInt32 channelCount, UInt32 dataCount, | |
372 | UInt32 dataWidth, void * data ); | |
373 | ||
374 | //// Controller attributes | |
375 | ||
376 | virtual IOReturn setAttribute( IOSelect attribute, UInt32 value ); | |
377 | virtual IOReturn getAttribute( IOSelect attribute, UInt32 * value ); | |
378 | ||
379 | //// Display mode timing information | |
380 | ||
381 | virtual IOReturn getTimingInfoForDisplayMode( | |
382 | IODisplayModeID displayMode, IOTimingInformation * info ); | |
383 | ||
384 | //// Detailed timing information | |
385 | ||
386 | virtual IOReturn validateDetailedTiming( | |
387 | void * description, IOByteCount descripSize ); | |
388 | ||
389 | virtual IOReturn setDetailedTimings( OSArray * array ); | |
390 | ||
391 | //// Connections | |
392 | ||
393 | virtual IOItemCount getConnectionCount( void ); | |
394 | ||
395 | virtual IOReturn setAttributeForConnection( IOIndex connectIndex, | |
396 | IOSelect attribute, UInt32 value ); | |
397 | virtual IOReturn getAttributeForConnection( IOIndex connectIndex, | |
398 | IOSelect attribute, UInt32 * value ); | |
399 | ||
400 | //// HW Cursors | |
401 | ||
402 | virtual bool convertCursorImage( void * cursorImage, | |
403 | IOHardwareCursorDescriptor * description, | |
404 | IOHardwareCursorInfo * cursor ); | |
405 | ||
406 | virtual IOReturn setCursorImage( void * cursorImage ); | |
407 | virtual IOReturn setCursorState( SInt32 x, SInt32 y, bool visible ); | |
408 | ||
409 | //// SW Cursors | |
410 | ||
411 | virtual void flushCursor( void ); | |
412 | ||
413 | // Apple sensing | |
414 | ||
415 | virtual IOReturn getAppleSense( IOIndex connectIndex, | |
416 | UInt32 * senseType, | |
417 | UInt32 * primary, | |
418 | UInt32 * extended, | |
419 | UInt32 * displayType ); | |
420 | ||
421 | virtual IOReturn connectFlags( IOIndex connectIndex, | |
422 | IODisplayModeID displayMode, IOOptionBits * flags ); | |
423 | ||
424 | //// IOLowLevelDDCSense | |
425 | ||
426 | virtual void setDDCClock( IOIndex connectIndex, UInt32 value ); | |
427 | virtual void setDDCData( IOIndex connectIndex, UInt32 value ); | |
428 | virtual bool readDDCClock( IOIndex connectIndex ); | |
429 | virtual bool readDDCData( IOIndex connectIndex ); | |
430 | virtual IOReturn enableDDCRaster( bool enable ); | |
431 | ||
432 | //// IOHighLevelDDCSense | |
433 | ||
434 | virtual bool hasDDCConnect( IOIndex connectIndex ); | |
435 | virtual IOReturn getDDCBlock( IOIndex connectIndex, UInt32 blockNumber, | |
436 | IOSelect blockType, IOOptionBits options, | |
437 | UInt8 * data, IOByteCount * length ); | |
438 | ||
439 | //// Interrupts | |
440 | ||
441 | // This is driven in the opposite direction to ndrv's ie. the base class | |
442 | // registers a proc with the driver, and controls int generation with | |
443 | // setInterruptState. Clients ask for serviceType. | |
444 | ||
445 | virtual IOReturn registerForInterruptType( IOSelect interruptType, | |
446 | IOFBInterruptProc proc, OSObject * target, void * ref, | |
447 | void ** interruptRef ); | |
448 | virtual IOReturn unregisterInterrupt( void * interruptRef ); | |
449 | virtual IOReturn setInterruptState( void * interruptRef, UInt32 state ); | |
450 | ||
451 | virtual IOReturn getNotificationSemaphore( IOSelect interruptType, | |
452 | semaphore_t * semaphore ); | |
453 | }; | |
454 | ||
455 | #endif /* ! _IOKIT_IOFRAMEBUFFER_H */ |