2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
26 * 30 Nov 98 sdouglas start cpp, from previous versions.
29 #ifndef _IOKIT_IOFRAMEBUFFER_H
30 #define _IOKIT_IOFRAMEBUFFER_H
32 #include <IOKit/IOService.h>
33 #include <IOKit/graphics/IOGraphicsDevice.h>
34 #include <IOKit/graphics/IOFramebufferShared.h>
35 #include <IOKit/IOLib.h>
38 class IOBufferMemoryDescriptor
;
40 typedef void (*CursorBlitProc
)(
43 volatile unsigned char *vramPtr
,
44 unsigned int cursStart
,
50 typedef void (*CursorRemoveProc
)(
53 volatile unsigned char *vramPtr
,
59 kTransparentEncoding
= 0,
64 kTransparentEncodingShift
= (kTransparentEncoding
<< 1),
65 kTransparentEncodedPixel
= (0x01 << kTransparentEncodingShift
),
67 kInvertingEncodingShift
= (kInvertingEncoding
<< 1),
68 kInvertingEncodedPixel
= (0x01 << kInvertingEncodingShift
),
72 kHardwareCursorDescriptorMajorVersion
= 0x0001,
73 kHardwareCursorDescriptorMinorVersion
= 0x0000
76 struct IOHardwareCursorDescriptor
{
84 UInt32
* colorEncodings
;
86 UInt32 supportedSpecialEncodings
;
87 UInt32 specialEncodings
[16];
89 typedef struct IOHardwareCursorDescriptor IOHardwareCursorDescriptor
;
92 kHardwareCursorInfoMajorVersion
= 0x0001,
93 kHardwareCursorInfoMinorVersion
= 0x0000
96 struct IOHardwareCursorInfo
{
101 // nil or big enough for hardware's max colors
102 IOColorEntry
* colorMap
;
103 UInt8
* hardwareCursorData
;
106 typedef struct IOHardwareCursorInfo IOHardwareCursorInfo
;
108 // clock & data values
114 // ddcBlockType constants
117 kIODDCBlockTypeEDID
= 0
120 // ddcFlags constants
122 // Force a new read of the EDID.
123 kIODDCForceRead
= 0x00000001,
127 kDisabledInterruptState
= 0,
128 kEnabledInterruptState
= 1
131 typedef void (*IOFBInterruptProc
)( OSObject
* target
, void * ref
);
134 typedef IOReturn (*IOFramebufferNotificationHandler
)
135 (OSObject
* self
, void * ref
,
136 IOFramebuffer
* framebuffer
, IOIndex event
,
139 // IOFramebufferNotificationHandler events
141 kIOFBNotifyDisplayModeWillChange
= 1,
142 kIOFBNotifyDisplayModeDidChange
,
143 kIOFBNotifyWillSleep
,
149 class IOFramebufferUserClient
;
151 class IOFramebuffer
: public IOGraphicsDevice
153 friend class IOFramebufferUserClient
;
154 friend class IOFramebufferSharedUserClient
;
155 friend class IOGraphicsEngineClient
;
157 OSDeclareDefaultStructors(IOFramebuffer
)
160 /*! @struct ExpansionData
161 @discussion This structure will be used to expand the capablilties of this class in the future.
163 struct ExpansionData
{ };
166 Reserved for future use. (Internal use only) */
167 ExpansionData
* reserved
;
173 int shmemClientVersion
;
174 IOBufferMemoryDescriptor
* sharedCursor
;
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
;
188 /* cursor blitting vars */
189 CursorBlitProc cursorBlitProc
;
190 CursorRemoveProc cursorRemoveProc
;
192 IOGSize maxCursorSize
;
193 volatile unsigned char * cursorImages
[ kIOFBNumCursorFrames
];
194 volatile unsigned char * cursorMasks
[ kIOFBNumCursorFrames
];
195 volatile unsigned char * cursorSave
;
201 semaphore_t vblSemaphore
;
204 volatile unsigned char * frameBuffer
;
205 unsigned int totalWidth
;
206 unsigned int rowBytes
;
207 unsigned int bytesPerPixel
;
209 IOMemoryMap
* vramMap
;
210 IOByteCount vramMapOffset
;
211 OSArray
* userAccessRanges
;
212 OSArray
* engineAccessRanges
;
213 IOBufferMemoryDescriptor
* engineContext
;
214 OSSet
* fbNotifications
;
216 class IOFramebufferUserClient
* serverConnect
;
217 class IOFramebufferSharedUserClient
* sharedConnect
;
223 bool needCursorService
;
230 /* Reserved for future expansion. */
231 int _IOFramebuffer_reserved
[7];
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);
269 static void initialize();
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
,
277 IOUserClient
** handler
);
280 virtual void hideCursor( void );
281 virtual void showCursor( Point
* cursorLoc
, int frame
);
282 virtual void moveCursor( Point
* cursorLoc
, int frame
);
284 void resetCursor( void );
286 virtual void getVBLTime( AbsoluteTime
* time
, AbsoluteTime
* delta
);
288 virtual void getBoundingRect ( Bounds
** bounds
);
290 virtual bool start( IOService
* provider
);
292 virtual IOReturn
open( void );
294 virtual void close( void );
296 virtual bool isConsoleDevice( void );
298 virtual IOReturn
setupForCurrentConfig( void );
300 virtual bool serializeInfo( OSSerialize
* s
);
301 virtual bool setNumber( OSDictionary
* dict
, const char * key
,
304 IONotifier
* addFramebufferNotification(
305 IOFramebufferNotificationHandler handler
,
306 OSObject
* self
, void * ref
);
308 virtual IODeviceMemory
* getApertureRange( IOPixelAperture aperture
) = 0;
309 virtual IODeviceMemory
* getVRAMRange( void );
313 IOReturn
deliverFramebufferNotification(
314 IOIndex event
, void * info
= 0 );
316 #ifdef IOFRAMEBUFFER_PRIVATE
317 #include <IOKit/graphics/IOFramebufferPrivate.h>
322 virtual IOReturn
enableController( void );
324 // List of pixel formats supported, null separated,
325 // doubly null terminated.
326 virtual const char * getPixelFormats( void ) = 0;
328 // Array of supported display modes
329 virtual IOItemCount
getDisplayModeCount( void ) = 0;
330 virtual IOReturn
getDisplayModes( IODisplayModeID
* allDisplayModes
) = 0;
332 // Info about a display mode
333 virtual IOReturn
getInformationForDisplayMode( IODisplayModeID displayMode
,
334 IODisplayModeInformation
* info
) = 0;
336 // Mask of pixel formats available in mode and depth
337 virtual UInt64
getPixelFormatsForDisplayMode( IODisplayModeID displayMode
,
340 virtual IOReturn
getPixelInformation(
341 IODisplayModeID displayMode
, IOIndex depth
,
342 IOPixelAperture aperture
, IOPixelInformation
* pixelInfo
) = 0;
346 // Current display mode and depth
347 virtual IOReturn
getCurrentDisplayMode( IODisplayModeID
* displayMode
,
348 IOIndex
* depth
) = 0;
350 // Set display mode and depth
351 virtual IOReturn
setDisplayMode( IODisplayModeID displayMode
,
355 virtual IOReturn
setApertureEnable( IOPixelAperture aperture
,
356 IOOptionBits enable
);
358 // Display mode and depth for startup
359 virtual IOReturn
setStartupDisplayMode( IODisplayModeID displayMode
,
361 virtual IOReturn
getStartupDisplayMode( IODisplayModeID
* displayMode
,
366 virtual IOReturn
setCLUTWithEntries( IOColorEntry
* colors
, UInt32 index
,
367 UInt32 numEntries
, IOOptionBits options
);
371 virtual IOReturn
setGammaTable( UInt32 channelCount
, UInt32 dataCount
,
372 UInt32 dataWidth
, void * data
);
374 //// Controller attributes
376 virtual IOReturn
setAttribute( IOSelect attribute
, UInt32 value
);
377 virtual IOReturn
getAttribute( IOSelect attribute
, UInt32
* value
);
379 //// Display mode timing information
381 virtual IOReturn
getTimingInfoForDisplayMode(
382 IODisplayModeID displayMode
, IOTimingInformation
* info
);
384 //// Detailed timing information
386 virtual IOReturn
validateDetailedTiming(
387 void * description
, IOByteCount descripSize
);
389 virtual IOReturn
setDetailedTimings( OSArray
* array
);
393 virtual IOItemCount
getConnectionCount( void );
395 virtual IOReturn
setAttributeForConnection( IOIndex connectIndex
,
396 IOSelect attribute
, UInt32 value
);
397 virtual IOReturn
getAttributeForConnection( IOIndex connectIndex
,
398 IOSelect attribute
, UInt32
* value
);
402 virtual bool convertCursorImage( void * cursorImage
,
403 IOHardwareCursorDescriptor
* description
,
404 IOHardwareCursorInfo
* cursor
);
406 virtual IOReturn
setCursorImage( void * cursorImage
);
407 virtual IOReturn
setCursorState( SInt32 x
, SInt32 y
, bool visible
);
411 virtual void flushCursor( void );
415 virtual IOReturn
getAppleSense( IOIndex connectIndex
,
419 UInt32
* displayType
);
421 virtual IOReturn
connectFlags( IOIndex connectIndex
,
422 IODisplayModeID displayMode
, IOOptionBits
* flags
);
424 //// IOLowLevelDDCSense
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
);
432 //// IOHighLevelDDCSense
434 virtual bool hasDDCConnect( IOIndex connectIndex
);
435 virtual IOReturn
getDDCBlock( IOIndex connectIndex
, UInt32 blockNumber
,
436 IOSelect blockType
, IOOptionBits options
,
437 UInt8
* data
, IOByteCount
* length
);
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.
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
);
451 virtual IOReturn
getNotificationSemaphore( IOSelect interruptType
,
452 semaphore_t
* semaphore
);
455 #endif /* ! _IOKIT_IOFRAMEBUFFER_H */