Chameleon

Chameleon Svn Source Tree

Root/branches/Chimera/i386/include/IOKit/graphics/IOFramebuffer.h

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#ifndef _IOKIT_IOFRAMEBUFFER_H
24#define _IOKIT_IOFRAMEBUFFER_H
25
26#include <IOKit/IOService.h>
27#include <IOKit/IOInterruptEventSource.h>
28#include <IOKit/graphics/IOGraphicsDevice.h>
29#include <IOKit/graphics/IOFramebufferShared.h>
30#include <IOKit/IOLib.h>
31
32class IOFramebuffer;
33class IOBufferMemoryDescriptor;
34
35typedef void (*CursorBlitProc)(
36 IOFramebuffer * inst,
37 void * shmem,
38 volatile unsigned char *vramPtr,
39 unsigned int cursStart,
40 unsigned int vramRow,
41 unsigned int cursRow,
42 int width,
43 int height );
44
45typedef void (*CursorRemoveProc)(
46 IOFramebuffer * inst,
47 void * shmem,
48 volatile unsigned char *vramPtr,
49 unsigned int vramRow,
50 int width,
51 int height );
52
53
54typedef void * IOFBCursorRef;
55
56struct IOFBCursorControlCallouts {
57 IOReturn (*setCursorImage) (void * self, void * ref,
58 IOHardwareCursorDescriptor * description, IOFBCursorRef cursorImage);
59 IOReturn (*setCursorState) (void * self, void * ref,
60 SInt32 x, SInt32 y, bool visible);
61 UInt32 reserved[30];
62};
63typedef struct IOFBCursorControlCallouts IOFBCursorControlCallouts;
64
65struct IOFBCursorControlAttribute {
66 void * self;
67 void * ref;
68 const IOFBCursorControlCallouts * callouts;
69 UInt32 reserved[29];
70};
71typedef struct IOFBCursorControlAttribute IOFBCursorControlAttribute;
72
73// clock & data values
74enum {
75 kIODDCLow = 0,
76 kIODDCHigh = 1,
77 kIODDCTristate = 2
78};
79// ddcBlockType constants
80enum {
81 // EDID block type.
82 kIODDCBlockTypeEDID = 0
83};
84
85// ddcFlags constants
86enum {
87 // Force a new read of the EDID.
88 kIODDCForceRead = 0x00000001
89};
90
91enum {
92 kDisabledInterruptState = 0,
93 kEnabledInterruptState = 1
94};
95
96typedef void (*IOFBInterruptProc)( OSObject * target, void * ref );
97
98
99typedef IOReturn (*IOFramebufferNotificationHandler)
100 (OSObject * self, void * ref,
101 IOFramebuffer * framebuffer, IOIndex event,
102 void * info);
103
104// IOFramebufferNotificationHandler events
105enum {
106 kIOFBNotifyDisplayModeWillChange = 1,
107 kIOFBNotifyDisplayModeDidChange = 2,
108
109 kIOFBNotifyWillSleep = 3,
110 kIOFBNotifyDidWake = 4,
111
112 kIOFBNotifyDidPowerOff = 5,
113 kIOFBNotifyWillPowerOn = 6,
114
115 kIOFBNotifyDidSleep = kIOFBNotifyDidPowerOff,
116 kIOFBNotifyWillWake = kIOFBNotifyWillPowerOn,
117
118 kIOFBNotifyWillPowerOff = 7,
119 kIOFBNotifyDidPowerOn = 8,
120
121 kIOFBNotifyWillChangeSpeed = 9,
122 kIOFBNotifyDidChangeSpeed = 10,
123
124 kIOFBNotifyClamshellChange = 20,
125
126 kIOFBNotifyCaptureChange = 30,
127
128 kIOFBNotifyOnlineChange = 40,
129
130 kIOFBNotifyDisplayDimsChange = 50,
131
132 kIOFBNotifyProbed = 60,
133};
134
135enum {
136 kFBDisplayUsablePowerState = 0x80000000,
137 kFBDisplayPowerStateMask = 0x0000ffff
138};
139
140#define kIOFBDependentIDKey "IOFBDependentID"
141#define kIOFBDependentIndexKey "IOFBDependentIndex"
142
143struct StdFBShmem_t;
144class IOFramebufferUserClient;
145
146/*! @class IOFramebuffer : public IOGraphicsDevice
147 @abstract The base class for graphics devices to be made available as part of the desktop.
148 @discussion The IOFramebuffer base class defines APIs used to publish a linear framebuffer device. Device driver writers should subclass this class to provide a X native driver. Mac OS X will also utilize 'ndrv' drivers via a subclass of IOFramebuffer IONDRVFramebuffer that does not require device driver writers to provide a X native driver.
149
150 There are no in kernel clients of IOFramebuffer aside from rudimentary console and panic UI supported by the IOFramebuffer class. The IOFramebuffer class provides the IOUserClient implementation to allow the CoreGraphics server to provide the user accessible interface to all displays on a Mac OS X system, and this is further layered underneath application frameworks. Device driver writers should not need any knowledge of this part of the interfaces. Similarly the instance variables of IOFramebuffer are mostly used for cursor rendering which is handled by the IOFramebuffer class, and should be avoided by subclass implementors. Only IOFramebuffer methods with header documentation in this header are designed for subclasses to implement.
151
152 IOFramebuffer provides simple dumb framebuffer operation - accceleration for 2D, 3D and video may be provided by a separate implementation of the IOAccelerator class.
153*/
154
155class IOFramebuffer : public IOGraphicsDevice
156{
157 friend class IOFramebufferUserClient;
158 friend class IOFramebufferSharedUserClient;
159 friend class IODisplay;
160
161 OSDeclareDefaultStructors(IOFramebuffer)
162
163protected:
164/*! @struct ExpansionData
165 @discussion This structure will be used to expand the capablilties of this class in the future.
166 */
167 struct ExpansionData { };
168
169/*! @var reserved
170 Reserved for future use. (Internal use only) */
171 ExpansionData * reserved;
172
173private:
174
175protected:
176 StdFBShmem_t * priv;
177 int shmemClientVersion;
178 IOBufferMemoryDescriptor * sharedCursor;
179
180 union {
181 struct {
182 /* Mapping tables used in cursor drawing to 5-5-5 displays. */
183 unsigned char * _bm34To35SampleTable;
184 unsigned char * _bm35To34SampleTable;
185 /* Mapping tables used in cursor drawing to 8-bit RGB displays. */
186 unsigned int * _bm256To38SampleTable;
187 unsigned char * _bm38To256SampleTable;
188 } t;
189 UInt8 * tables[ 4 ];
190 } colorConvert;
191
192 /* cursor blitting vars */
193 CursorBlitProc cursorBlitProc;
194 CursorRemoveProc cursorRemoveProc;
195
196 IOGSize maxCursorSize;
197 void * _IOFramebuffer_reservedE[7];
198 const char * thisName;
199 volatile unsigned char * cursorSave;
200 unsigned int white;
201
202 IOGPoint nextCursorLoc;
203 int nextCursorFrame;
204 SInt32 connectChange;
205 semaphore_t vblSemaphore;
206
207 /* memory ranges */
208 volatile unsigned char * frameBuffer;
209 unsigned int totalWidth;
210 unsigned int rowBytes;
211 unsigned int bytesPerPixel;
212
213 IOMemoryMap * vramMap;
214 IOByteCount vramMapOffset;
215 OSArray * userAccessRanges;
216 unsigned int suspended:1;
217 unsigned int captured:1;
218 unsigned int sleepConnectCheck:1;
219 unsigned int messaged:1;
220 unsigned int _IOFramebuffer_reservedC:28;
221 IOFramebuffer * nextDependent;
222 OSSet * fbNotifications;
223
224 class IOFramebufferUserClient * serverConnect;
225 class IOFramebufferSharedUserClient * sharedConnect;
226
227 unsigned int opened:1;
228 unsigned int dead:1;
229 unsigned int configPending:1;
230 unsigned int serverNotified:1;
231 unsigned int serverState:1;
232 unsigned int serverPendingAck:1;
233 unsigned int isUsable:1;
234 unsigned int mirrored:1;
235 unsigned int pendingPowerState:4;
236 unsigned int pendingPowerChange:1;
237 unsigned int pagingState:1;
238 unsigned int mirrorPrimary:1;
239 unsigned int mirrorSWCursor:1;
240
241 bool clutValid;
242 bool currentMono;
243 bool needCursorService;
244 bool haveVBLService;
245 bool haveHWCursor;
246 bool hwCursorLoaded;
247
248 void * serverMsg;
249 IOInterruptEventSource * deferredEvents;
250
251 /* Reserved for future expansion. */
252 int _IOFramebuffer_reserved[5];
253
254private:
255 struct IOFramebufferPrivate * __private;
256
257public:
258/*! @function doI2CRequest
259 @abstract Carry out an I2C request.
260 @discussion IOFramebuffer subclasses may optionally implement this method to perform I2C bus requests on one of the buses they support. Alternatively they may implement the setDDCClock(), setDDCData(), readDDCClock(), readDDCData() methods and respond from getAttributeForConnection() to the kConnectionSupportsLLDDCSense attribute with success, in which case IOFramebuffer::doI2CRequest() will carry out a software implementation of I2C using the low level routines and conforming to the timing constraints passed in the timing parameter. Subclasses may pass timing parameters tuned for the specific bus, otherwise VESA DDC defaults will apply.
261 @timing event Subclasses may pass timing parameters tuned for the specific bus, otherwise if NULL, VESA DDC defaults will apply.
262 @param request An IOI2CRequest structure. The request should be carried out synchronously if the completion routine is NULL, otherwise it may optionally be carried out asynchronously. The completion routine should be called if supplied.
263 @result an IOReturn code. If kIOReturnSuccces, the result of the transaction is returned in the requests result field.
264*/
265 virtual IOReturn doI2CRequest( UInt32 bus, struct IOI2CBusTiming * timing, struct IOI2CRequest * request );
266
267private:
268 OSMetaClassDeclareReservedUsed(IOFramebuffer, 0);
269
270 OSMetaClassDeclareReservedUnused(IOFramebuffer, 1);
271 OSMetaClassDeclareReservedUnused(IOFramebuffer, 2);
272 OSMetaClassDeclareReservedUnused(IOFramebuffer, 3);
273 OSMetaClassDeclareReservedUnused(IOFramebuffer, 4);
274 OSMetaClassDeclareReservedUnused(IOFramebuffer, 5);
275 OSMetaClassDeclareReservedUnused(IOFramebuffer, 6);
276 OSMetaClassDeclareReservedUnused(IOFramebuffer, 7);
277 OSMetaClassDeclareReservedUnused(IOFramebuffer, 8);
278 OSMetaClassDeclareReservedUnused(IOFramebuffer, 9);
279 OSMetaClassDeclareReservedUnused(IOFramebuffer, 10);
280 OSMetaClassDeclareReservedUnused(IOFramebuffer, 11);
281 OSMetaClassDeclareReservedUnused(IOFramebuffer, 12);
282 OSMetaClassDeclareReservedUnused(IOFramebuffer, 13);
283 OSMetaClassDeclareReservedUnused(IOFramebuffer, 14);
284 OSMetaClassDeclareReservedUnused(IOFramebuffer, 15);
285 OSMetaClassDeclareReservedUnused(IOFramebuffer, 16);
286 OSMetaClassDeclareReservedUnused(IOFramebuffer, 17);
287 OSMetaClassDeclareReservedUnused(IOFramebuffer, 18);
288 OSMetaClassDeclareReservedUnused(IOFramebuffer, 19);
289 OSMetaClassDeclareReservedUnused(IOFramebuffer, 20);
290 OSMetaClassDeclareReservedUnused(IOFramebuffer, 21);
291 OSMetaClassDeclareReservedUnused(IOFramebuffer, 22);
292 OSMetaClassDeclareReservedUnused(IOFramebuffer, 23);
293 OSMetaClassDeclareReservedUnused(IOFramebuffer, 24);
294 OSMetaClassDeclareReservedUnused(IOFramebuffer, 25);
295 OSMetaClassDeclareReservedUnused(IOFramebuffer, 26);
296 OSMetaClassDeclareReservedUnused(IOFramebuffer, 27);
297 OSMetaClassDeclareReservedUnused(IOFramebuffer, 28);
298 OSMetaClassDeclareReservedUnused(IOFramebuffer, 29);
299 OSMetaClassDeclareReservedUnused(IOFramebuffer, 30);
300 OSMetaClassDeclareReservedUnused(IOFramebuffer, 31);
301
302
303public:
304 static void initialize();
305
306 virtual bool requestTerminate( IOService * provider, IOOptionBits options );
307 virtual IOService * probe( IOService * provider, SInt32 * score );
308 virtual bool start( IOService * provider );
309 virtual void stop( IOService * provider );
310 virtual void free();
311 virtual IOWorkLoop * getWorkLoop() const;
312
313 IOWorkLoop * getGraphicsSystemWorkLoop() const;
314 IOWorkLoop * getControllerWorkLoop() const;
315
316 virtual IOReturn requestProbe( IOOptionBits options );
317
318 virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService* );
319 virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService* );
320 virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService * device);
321 virtual IOReturn setAggressiveness( unsigned long type, unsigned long newLevel );
322 virtual IOReturn getAggressiveness( unsigned long type, unsigned long * currentLevel );
323 virtual IOReturn newUserClient( task_t owningTask,
324 void * security_id,
325 UInt32 type,
326 IOUserClient ** handler );
327 virtual IOReturn callPlatformFunction( const OSSymbol * functionName,
328 bool waitForFunction,
329 void *p1, void *p2,
330 void *p3, void *p4 );
331
332 virtual void hideCursor( void );
333 virtual void showCursor( IOGPoint * cursorLoc, int frame );
334 virtual void moveCursor( IOGPoint * cursorLoc, int frame );
335 // virtual
336 void resetCursor( void );
337
338 virtual void getVBLTime( AbsoluteTime * time, AbsoluteTime * delta );
339
340 virtual void getBoundingRect ( IOGBounds ** bounds );
341
342 virtual IOReturn open( void );
343
344 virtual void close( void );
345
346 virtual bool isConsoleDevice( void );
347
348 virtual IOReturn setupForCurrentConfig( void );
349
350 virtual bool serializeInfo( OSSerialize * s );
351 virtual bool setNumber( OSDictionary * dict, const char * key,
352 UInt32 number );
353
354 IONotifier * addFramebufferNotification(
355 IOFramebufferNotificationHandler handler,
356 OSObject * self, void * ref);
357
358/*! @function getApertureRange
359 @abstract Return reference to IODeviceMemory object representing memory range of framebuffer.
360 @discussion IOFramebuffer subclasses must implement this method to describe the memory used by the framebuffer in the current mode. The OS will map this memory range into user space for client access - the range should only include vram memory not hardware registers.
361 @param aperture The system will only access the aperture kIOFBSystemAperture.
362 @result an IODeviceMemory instance. A reference will be consumed by the caller for each call of this method - the implementatation should create a new instance of IODeviceMemory for each call, or return one instance with a retain for each call.
363*/
364
365 virtual IODeviceMemory * getApertureRange( IOPixelAperture aperture ) = 0;
366
367/*! @function getVRAMRange
368 @abstract Return reference to IODeviceMemory object representing memory range of all the cards vram.
369 @discussion IOFramebuffer subclasses should implement this method to describe all the vram memory available on the card. The OS will map this memory range into user space for client access - the range should only include vram memory not hardware registers.
370 @result an IODeviceMemory instance. A reference will be consumed by the caller for each call of this method - the implementatation should create a new instance of IODeviceMemory for each call, or return one instance with a retain for each call.
371*/
372
373 virtual IODeviceMemory * getVRAMRange( void );
374
375protected:
376
377/*! @function handleEvent
378 @abstract Notify IOFramebuffer superclass code of events.
379 @discussion IOFramebuffer subclasses should call this IOFramebuffer method on certain power state changes.
380 @param event The event that has occurred:<br>
381 kIOFBNotifyWillPowerOff call before entering a state other than the maximum.<br>
382 kIOFBNotifyDidPowerOn call after entering the maximum power state.<br>
383 kIOFBNotifyWillPowerOff call before entering a state other than the maximum.<br>
384 kIOFBNotifyDidPowerOn call after entering a state other than the maximum.<br>
385 @param info None of the above events require additional info, pass zero.
386 @result an IOReturn code, safely ignored.
387*/
388
389 IOReturn handleEvent( IOIndex event, void * info = 0 );
390
391
392 IOReturn deliverFramebufferNotification(
393 IOIndex event, void * info = 0 );
394
395#ifdef IOFRAMEBUFFER_PRIVATE
396#include <IOKit/graphics/IOFramebufferPrivate.h>
397#endif
398
399public:
400/*! @function enableController
401 @abstract Perform first time setup of the framebuffer.
402 @discussion IOFramebuffer subclasses should perform their initialization of the hardware here. The IOService start() method is not called at a time appropriate for this initialization.
403 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device.
404*/
405
406 virtual IOReturn enableController( void );
407
408/*! @function getPixelFormats
409 @abstract List the pixel formats the framebuffer supports.
410 @discussion IOFramebuffer subclasses must implement this method to return an array of strings representing the possible pixel formats available in the framebuffer.
411 @result A const char * pointer. The string consists of a concatenation of each pixel format string separated by the NULL character. The commonly supported pixel formats for Mac OS X are defined as IO8BitIndexedPixels, IO16BitDirectPixels, IO32BitDirectPixels.
412*/
413
414 virtual const char * getPixelFormats( void ) = 0;
415
416/*! @function getDisplayModeCount
417 @abstract Return the number of display modes the framebuffer supports.
418 @discussion IOFramebuffer subclasses must implement this method to return a count of the display modes available. This count should change unless a connection change is posted for the device indicated the framebuffer and/or display configuration has changed.
419 @result A count of the display modes available.
420*/
421
422 virtual IOItemCount getDisplayModeCount( void ) = 0;
423
424/*! @function getDisplayModes
425 @abstract Return the number of display modes the framebuffer supports.
426 @discussion IOFramebuffer subclasses must implement this method to return an array of display mode IDs available for the framebuffer. The IDs are defined by the driver in the range 0x00000001 - 0x7fffffff, and should be constant for a given display mode.
427 @param allDisplayModes A caller allocated buffer with the size given by the result of getDisplayModeCount().
428 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device.
429*/
430
431 virtual IOReturn getDisplayModes( IODisplayModeID * allDisplayModes ) = 0;
432
433/*! @function getInformationForDisplayMode
434 @abstract Return information about a given display mode.
435 @discussion IOFramebuffer subclasses must implement this method to return information in the IODisplayModeInformation structure for the display mode with the passed ID.
436 @param displayMode A display mode ID previously returned by getDisplayModes().
437 @param info Pointer to a structure of type IODisplayModeInformation to be filled out by the driver. IODisplayModeInformation is documented in IOGraphicsTypes.h.
438 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device.
439*/
440
441 virtual IOReturn getInformationForDisplayMode( IODisplayModeID displayMode,
442 IODisplayModeInformation * info ) = 0;
443
444/*! @function getPixelFormatsForDisplayMode
445 @abstract Obsolete.
446 @discussion IOFramebuffer subclasses must implement this method to return zero.
447 @param displayMode Ignored.
448 @param depth Ignored.
449 @result Return zero.
450*/
451
452 virtual UInt64 getPixelFormatsForDisplayMode( IODisplayModeID displayMode,
453 IOIndex depth ) = 0;
454
455/*! @function getPixelInformation
456 @abstract Return information about the framebuffer format for a given display mode and depth.
457 @discussion IOFramebuffer subclasses must implement this method to return information in the IOPixelInformation structure for the display mode with the passed ID, depth index and aperture. The aperture utilized by the system is always kIOFBSystemAperture. Drivers may define alternative apertures, being a view of the framebuffer in a different pixel format from the default.
458 @param displayMode A display mode ID previously returned by getDisplayModes().
459 @param depth An index from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure (inclusive).
460 @param info Pointer to a structure of type IOPixelInformation to be filled out by the driver. IOPixelInformation is documented in IOGraphicsTypes.h.
461 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device.
462*/
463
464 virtual IOReturn getPixelInformation(
465 IODisplayModeID displayMode, IOIndex depth,
466 IOPixelAperture aperture, IOPixelInformation * pixelInfo ) = 0;
467
468/*! @function getCurrentDisplayMode
469 @abstract Return the framebuffers current display mode and depth.
470 @discussion IOFramebuffer subclasses must implement this method to return the current mode and depth.
471 @param displayMode A display mode ID representing the current mode.
472 @param depth An index indicating the depth configuration of the framebuffer. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode.
473 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device.
474*/
475
476 virtual IOReturn getCurrentDisplayMode( IODisplayModeID * displayMode,
477 IOIndex * depth ) = 0;
478
479/*! @function setCurrentDisplayMode
480 @abstract Set the framebuffers current display mode and depth.
481 @discussion IOFramebuffer subclasses should implement this method to set the current mode and depth. Other than at enableController() time, this is the only method that should change the framebuffer format and is synchronized with clients and attached accelerators to make sure access to the device is disallowed during the change.
482 @param displayMode A display mode ID representing the new mode.
483 @param depth An index indicating the new depth configuration of the framebuffer. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode.
484 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device.
485*/
486
487 virtual IOReturn setDisplayMode( IODisplayModeID displayMode,
488 IOIndex depth );
489
490/*! @function setApertureEnable
491 @abstract Enable an aperture on the framebuffer (usually unimplemented, no OS usage).
492 @discussion IOFramebuffer subclasses may implement this method to set enable a non standard aperture. The system does not call this method.
493 @param aperture A device specific aperture index.
494 @param enable Device specific mask of options.
495 @result an IOReturn code.
496*/
497
498 virtual IOReturn setApertureEnable( IOPixelAperture aperture,
499 IOOptionBits enable );
500
501/*! @function setStartupDisplayMode
502 @abstract Set the framebuffers display mode and depth to be used during boot and at startup.
503 @discussion IOFramebuffer subclasses should implement this method to set the mode and depth to be used during boot and at startup, to reduce needed mode changes during boot when the display connection type is the same. If possible this mode should also be used by the OpenFirmware driver for the card.
504 @param displayMode A display mode ID representing the new startup mode.
505 @param depth An index indicating the new startup depth configuration of the framebuffer. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode.
506 @result an IOReturn code.
507*/
508
509 virtual IOReturn setStartupDisplayMode( IODisplayModeID displayMode,
510 IOIndex depth );
511
512/*! @function getCurrentDisplayMode
513 @abstract Return the framebuffers display mode and depth to be used during boot and at startup.
514 @discussion IOFramebuffer subclasses should implement this method to return the current mode and depth.
515 @param displayMode A display mode ID representing the mode used during startup.
516 @param depth An index indicating the depth configuration of the framebuffer used during startup. The index should range from zero to the value of the maxDepthIndex field from the IODisplayModeInformation structure for the display mode.
517 @result an IOReturn code.
518*/
519
520 virtual IOReturn getStartupDisplayMode( IODisplayModeID * displayMode,
521 IOIndex * depth );
522
523/*! @function setCLUTWithEntries
524 @abstract Set the color lookup table to be used by the framebuffer in indexed modes.
525 @discussion IOFramebuffer subclasses may implement this method to allow a palette to be set for indexed display modes. It will not be called on framebuffers in direct display modes.
526 @param colors A pointer to an array of numEntries RGB color entries.
527 @param index The index of the first entry to set.
528 @param numEntries The number of entries in the table.
529 @param options Options controlling the operation. <br>
530 kSetCLUTByValue is set if the index field of each entry should be used to set the table sparsely, otherwise consecutive entries from the index parameter should be set.<br>
531 kSetCLUTImmediately is set if the CLUT set should not be synchronized with the vertical blank, otherwise it should.<br>
532 kSetCLUTWithLuminance is set if the CLUT should be set to a gray value equivalent in luminance to the passed color entry.<br>
533 @result an IOReturn code.
534*/
535
536 virtual IOReturn setCLUTWithEntries( IOColorEntry * colors, UInt32 index,
537 UInt32 numEntries, IOOptionBits options );
538
539/*! @function setGammaTable
540 @abstract Set the gamma table to be used by the framebuffer.
541 @discussion IOFramebuffer subclasses should implement this method to allow a gamma table to be set.
542 @param channelCount Defines the number of channels in the supplied data. OS X will pass three for separate R, G, B data, or one if the same data should apply to all channels.
543 @param dataCount The number of data entries per channel.
544 @param dataWidth The number of bits in each entry. 8 for Mac OS X 10.1 and earlier, 16 for later releases.
545 @param data The packed array of correction data. Data is passed for the R (or single) channel followed by the G & B channels. Each entry is one or two bytes (if dataWidth > 8).
546 @result an IOReturn code.
547*/
548
549 virtual IOReturn setGammaTable( UInt32 channelCount, UInt32 dataCount,
550 UInt32 dataWidth, void * data );
551
552/*! @function setAttribute
553 @abstract Generic method to set some attribute of the framebuffer device.
554 @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be set.
555 @param attribute Defines the attribute to be set. Some defined attributes are:<br>
556 kIOPowerAttribute The IOFramebuffer class implements most power management (IOService) methods. It calls the subclass to carry out the power management state change with this attribute. When carrying out power state changes, the subclass should call IOFramebuffer::handleEvent for certain changes - set that method for more information.
557 @param value The new value for the attribute.
558 @result an IOReturn code.
559*/
560
561 virtual IOReturn setAttribute( IOSelect attribute, uintptr_t value );
562
563/*! @function getAttribute
564 @abstract Generic method to retrieve some attribute of the framebuffer device.
565 @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be returned.
566 @param attribute Defines the attribute to be set. Some defined attributes are:<br>
567 kIOHardwareCursorAttribute If the device supports a hardware cursor and implements the setCursorImage() and setCursorState() calls it should return true for this attribute.
568 @param value Returns the value for the attribute.
569 @result an IOReturn code.
570*/
571
572 virtual IOReturn getAttribute( IOSelect attribute, uintptr_t * value );
573
574/*! @function getTimingInfoForDisplayMode
575 @abstract Returns a timing description for a display mode.
576 @discussion IOFramebuffer subclasses should implement this method to return timing information for a display mode. This allows the OS to enable display modes based on its knowledge of the connected display type. Two types of timing information are defined, by Apple defined constant, or by a detailed description of the timing parameters of the mode.
577 @param displayMode A display mode ID representing the mode to examine.
578 @param info The driver returns the information for the display mode in this structure.<br>
579 If the mode has an Apple defined constant, such as timingVESA_1024x768_75hz, it should be returned in the appleTimingID field. Otherwise the field should be set to timingInvalid.<br>
580 If the driver is able to supply detailed timing information, it should return it in the detailedInfo.v2 field of the structure, otherwise the driver should clear the kIODetailedTimingValid flag from the flags field.<br>
581 The IODetailedTimingInformationV2 structure is documented in IOGraphicsTypes.h
582 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device.
583*/
584
585 virtual IOReturn getTimingInfoForDisplayMode(
586 IODisplayModeID displayMode, IOTimingInformation * info );
587
588/*! @function validateDetailedTiming
589 @abstract Reports whether a detailed timing is able to be programmed with the device.
590 @discussion IOFramebuffer subclasses may implement programmable mode functionality where the OS is able to install modes described by a detailed timing into the driver.
591 @param description A pointer to a IODetailedTimingInformationV2 structure. The driver should examine this description and change any fields that it cannot implement to reflect its closest possible implementation.
592 @param descripSize sizeof(IODetailedTimingInformationV2)
593 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from installing the programmable mode.
594*/
595
596 virtual IOReturn validateDetailedTiming(
597 void * description, IOByteCount descripSize );
598
599/*! @function setDetailedTimings
600 @abstract Installs an array of OS programmed detailed timings to be made available by the driver.
601 @discussion IOFramebuffer subclasses may implement programmable mode functionality where the OS is able to install modes described by a detailed timing into the driver. The driver needs to add these modes to its internal mode list if it provides this functionality.
602 @param array An OSArray of OSData objects. Each OSData contains one IODetailedTimingInformationV2 structure. All the data described by the array should be copied or retained by this call until the next invocation of this method.
603 @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from installing the programmable modes.
604*/
605
606 virtual IOReturn setDetailedTimings( OSArray * array );
607
608/*! @function getConnectionCount
609 @abstract Reports the number of display connections the device supports, driven from one framebuffer.
610 @discussion IOFramebuffer subclasses may implement functionality where a single framebuffer drives multiple displays. This is not recommended or fully supported and instead multihead cards should implement multiple instances of IOFramebuffer objects to provide full functionality.
611 @result A count of the number of display connections reported by the framebuffer. Current versions of OS X only support one connection completely.
612*/
613
614 virtual IOItemCount getConnectionCount( void );
615
616
617/*! @function setAttributeForConnection
618 @abstract Generic method to set some attribute of the framebuffer device, specific to one display connection.
619 @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be set, specific to one display connection.
620 @param attribute Defines the attribute to be set. Some defined attributes are:<br>
621 kIOCapturedAttribute If the device supports hotplugging displays, it should disable the generation of hot plug interrupts when the attribute kIOCapturedAttribute is set to true.
622 @param value The new value for the attribute.
623 @result an IOReturn code.
624*/
625
626 virtual IOReturn setAttributeForConnection( IOIndex connectIndex,
627 IOSelect attribute, uintptr_t value );
628
629/*! @function getAttributeForConnection
630 @abstract Generic method to retrieve some attribute of the framebuffer device, specific to one display connection.
631 @discussion IOFramebuffer subclasses may implement this method to allow arbitrary attribute/value pairs to be returned, specific to one display connection.
632 @param attribute Defines the attribute to be returned. Some defined attributes are:<br>
633 kConnectionSupportsHLDDCSense If the framebuffer supports the DDC methods hasDDCConnect() and getDDCBlock() it should return success (and no value) for this attribute.<br>
634 kConnectionSupportsLLDDCSense If the framebuffer wishes to make use of IOFramebuffer::doI2CRequest software implementation of I2C it should implement the I2C methods setDDCClock(), setDDCData(), readDDCClock(), readDDCData(), and it should return success (and no value) for this attribute.<br>
635 @param value Returns the value for the attribute.
636 @result an IOReturn code.
637*/
638
639 virtual IOReturn getAttributeForConnection( IOIndex connectIndex,
640 IOSelect attribute, uintptr_t * value );
641
642/*! @function convertCursorImage
643 @abstract Utility method of IOFramebuffer to convert cursor image to a hardware cursor format.
644 @discussion IOFramebuffer subclasses may implement hardware cursor functionality, if so they should pass the cursor image given by the setCursorImage() method, with a description of their hardware cursor format, to this helper function to this routine to convert the image to one suitable for the hardware.
645 @param cursorImage Opaque cursor parameter from the setCursorImage() call.
646 @param description Describes the cursor format supported by the driver.
647 @param cursor Structure describing the drivers allocated buffer to receive the converted image.
648 @result a bool indicating the conversion was successful.
649*/
650
651 virtual bool convertCursorImage( void * cursorImage,
652 IOHardwareCursorDescriptor * description,
653 IOHardwareCursorInfo * cursor );
654
655/*! @function setCursorImage
656 @abstract Set a new image for the hardware cursor.
657 @discussion IOFramebuffer subclasses may implement hardware cursor functionality, if so they should implement this method to change the hardware cursor image. The image should be passed to the convertCursorImage() method with each type of cursor format the hardware supports until success, if all fail the hardware cursor should be hidden and kIOReturnUnsupported returned.
658 @param cursorImage Opaque cursor description. This should be passed to the convertCursorImage() method to convert to a format specific to the hardware.
659 @result An IOReturn code.
660*/
661
662 virtual IOReturn setCursorImage( void * cursorImage );
663
664/*! @function setCursorState
665 @abstract Set a new position and visibility for the hardware cursor.
666 @discussion IOFramebuffer subclasses may implement hardware cursor functionality, if so they should implement this method to change the position and visibility of the cursor.
667 @param x Left coordinate of the cursor image. A signed value, will be negative if the cursor's hot spot and position place it partly offscreen.
668 @param y Top coordinate of the cursor image. A signed value, will be negative if the cursor's hot spot and position place it partly offscreen.
669 @param visible Visible state of the cursor.
670 @result An IOReturn code.
671*/
672
673 virtual IOReturn setCursorState( SInt32 x, SInt32 y, bool visible );
674
675/*! @function flushCursor
676 @abstract Perform any needed cache flushing after software cursor rendering.
677 @discussion IOFramebuffer implements software cursor functionality when a hardware cursor is unavailable. Some hardware may need to flush a cache after the processor has finished lifting and dropping the software cursor.
678*/
679
680 virtual void flushCursor( void );
681
682/*! @function getAppleSense
683 @abstract Return display sense information for legacy Apple sensing.
684 @discussion Hardware that supports simple display sensing, or the classic 3 pin Apple sensing described in Designing Cards and Drivers, should implement this method to return sense information.
685 @param connectIndex Index of the display connection, from zero to the value of getConnectionCount().
686 @param senseType Return zero to indicate legacy Apple sensing.
687 @param primary Return the value of the primary Apple sense code.
688 @param extended Return the value of the secondary Apple sense code.
689 @param displayType Return an Apple defined constant for the type of display sensed. For example, kVGAConnect, kNTSCConnect, kPALConnect etc.
690 @result An IOReturn code.
691*/
692
693 virtual IOReturn getAppleSense( IOIndex connectIndex,
694 UInt32 * senseType,
695 UInt32 * primary,
696 UInt32 * extended,
697 UInt32 * displayType );
698
699/*! @function connectFlags
700 @abstract Return display sense information for legacy Apple sensing.
701 @discussion Hardware that supports simple display sensing, or the classic 3 pin Apple sensing described in Designing Cards and Drivers, should implement this method to return mode flags relative to the sensed display. If this method is unimplemented, all modes have are given the flags kDisplayModeValidFlag | kDisplayModeSafeFlag.
702 @param connectIndex Index of the display connection, from zero to the value of getConnectionCount().
703 @param displayMode A display mode ID.
704 @param flags Return the flags value for the given mode with the connected display. Flags are:<br>
705 kDisplayModeValidFlag - mode is considered valid for the connected display by the driver.
706 kDisplayModeSafeFlag - mode is considered safe (not requiring mode change confirmation) for the connected display by the driver.
707 kDisplayModeDefaultFlag - mode is considered default for the connected display by the driver.
708 @result An IOReturn code.
709*/
710
711 virtual IOReturn connectFlags( IOIndex connectIndex,
712 IODisplayModeID displayMode, IOOptionBits * flags );
713
714 //// IOLowLevelDDCSense
715
716/*! @function setDDCClock
717 @abstract Sets the state of the I2C clock line on a bus.
718 @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to set the state of the I2C clock line on the given bus. Otherwise may be unimplemented.
719 @param bus Index of the bus.
720 @param value One of kIODDCLow, kIODDCHigh, kIODDCTristate.
721*/
722
723 virtual void setDDCClock( IOIndex bus, UInt32 value );
724
725/*! @function setDDCData
726 @abstract Sets the state of the I2C data line on a bus.
727 @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to set the state of the I2C data line on the given bus. Otherwise may be unimplemented.
728 @param bus Index of the bus.
729 @param value One of kIODDCLow, kIODDCHigh, kIODDCTristate.
730*/
731 virtual void setDDCData( IOIndex bus, UInt32 value );
732
733/*! @function readDDCClock
734 @abstract Reads the input state of the I2C clock line on a bus.
735 @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to return the input state of the I2C clock line on the given bus. Otherwise may be unimplemented.
736 @param bus Index of the bus.
737 @result A boolean reflecting the current state of the clock line on the given bus.
738*/
739 virtual bool readDDCClock( IOIndex bus );
740
741/*! @function readDDCData
742 @abstract Reads the input state of the I2C data line on a bus.
743 @discussion Framebuffers making use of the IOFramebuffer::doI2CRequest() software implementation of I2C should implement this method to return the input state of the I2C data line on the given bus. Otherwise may be unimplemented.
744 @param bus Index of the bus.
745 @result A boolean reflecting the current state of the data line on the given bus.
746*/
747 virtual bool readDDCData( IOIndex bus );
748
749 virtual IOReturn enableDDCRaster( bool enable );
750
751/*! @function hasDDCConnect
752 @abstract Return display DDC connect state.
753 @discussion Hardware that supports DDC/EDID display sensing should implement this method to return true if a DDC display is detected. They should also return success for the connection attribute kConnectionSupportsHLDDCSense (from getAttributeForConnection()).
754 @param connectIndex Index of the display connection, from zero to the value of getConnectionCount().
755 @result True if a DDC display is detected.
756*/
757
758 virtual bool hasDDCConnect( IOIndex connectIndex );
759
760/*! @function getDDCBlock
761 @abstract Return display EDID data.
762 @discussion Hardware that supports DDC/EDID display sensing should implement this method to return EDID data in 128 byte blocks.
763 @param connectIndex Index of the display connection, from zero to the value of getConnectionCount().
764 @param blockNumber Block number, ranging from one to the number of blocks return by the display.
765 @param blockType kIODDCBlockTypeEDID will be passed.
766 @param options No options are currently defined.
767 @param data Caller allocated buffer to receive the blocks data.
768 @param length In/out parameter - callers allocated buffer size, driver returns actual size.
769 @result An IOReturn code.
770*/
771
772 virtual IOReturn getDDCBlock( IOIndex connectIndex, UInt32 blockNumber,
773 IOSelect blockType, IOOptionBits options,
774 UInt8 * data, IOByteCount * length );
775
776/*! @function registerForInterruptType
777 @abstract Set callbacks for driver to call on interrupt events.
778 @discussion The IOFramebuffer class will call its subclasses to set callbacks to be called on interrupt events generated by hardware events. Only two are currently in use - vertical blank interrupts and connection changed interrupts.
779 @param interruptType One of these constants:<br>
780 kIOFBVBLInterruptType Specifying a vertical blanking interrupt.
781 kIOFBConnectInterruptType Specify the display connection should be resensed.
782 @param proc C callback to be called by the driver when the specified event occurs.
783 @param target Target parameter for the callback proc.
784 @param ref Ref parameter for the callback proc.
785 @param interruptRef The subclass should return an opaque reference to the installed interrupt handler, for use with unregisterInterrupt() and setInterruptState().
786 @result An IOReturn code.
787*/
788
789 virtual IOReturn registerForInterruptType( IOSelect interruptType,
790 IOFBInterruptProc proc, OSObject * target, void * ref,
791 void ** interruptRef );
792
793/*! @function unregisterInterrupt
794 @abstract Remove a callback previously installed by registerForInterruptType().
795 @discussion Remove a callback previously installed by registerForInterruptType().
796 @param interruptRef The interruptRef returned from the registerForInterruptType call that installed the interrupt.
797 @result An IOReturn code.
798*/
799
800 virtual IOReturn unregisterInterrupt( void * interruptRef );
801
802/*! @function unregisterInterrupt
803 @abstract Enable or disable a callback previously installed by registerForInterruptType().
804 @discussion Enable or disable a callback previously installed by registerForInterruptType().
805 @param state True or false to enable the callback.
806 @result An IOReturn code.
807*/
808
809 virtual IOReturn setInterruptState( void * interruptRef, UInt32 state );
810
811 virtual IOReturn getNotificationSemaphore( IOSelect interruptType,
812 semaphore_t * semaphore );
813
814/* non WL clients apis
815*/
816 IOReturn setAttributeExt( IOSelect attribute, uintptr_t value );
817
818 IOReturn getAttributeExt( IOSelect attribute, uintptr_t * value );
819
820 IOReturn setAttributeForConnectionExt( IOIndex connectIndex,
821 IOSelect attribute, uintptr_t value );
822
823 IOReturn getAttributeForConnectionExt( IOIndex connectIndex,
824 IOSelect attribute, uintptr_t * value );
825};
826
827#endif /* ! _IOKIT_IOFRAMEBUFFER_H */
828

Archive Download this file

Revision: 1340