|
|
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: * 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: };
144:
145:
146: struct StdFBShmem_t;
147: class IOFramebufferUserClient;
148:
149: class IOFramebuffer : public IOGraphicsDevice
150: {
151: friend class IOFramebufferUserClient;
152: friend class IOFramebufferSharedUserClient;
153: friend class IOGraphicsEngineClient;
154:
155: OSDeclareDefaultStructors(IOFramebuffer)
156: private:
157:
158: protected:
159: StdFBShmem_t * priv;
160: int shmemClientVersion;
161: IOBufferMemoryDescriptor * sharedCursor;
162:
163: union {
164: struct {
165: /* Mapping tables used in cursor drawing to 5-5-5 displays. */
166: unsigned char * _bm34To35SampleTable;
167: unsigned char * _bm35To34SampleTable;
168: /* Mapping tables used in cursor drawing to 8-bit RGB displays. */
169: unsigned int * _bm256To38SampleTable;
170: unsigned char * _bm38To256SampleTable;
171: } t;
172: UInt8 * tables[ 4 ];
173: } colorConvert;
174:
175: /* cursor blitting vars */
176: CursorBlitProc cursorBlitProc;
177: CursorRemoveProc cursorRemoveProc;
178:
179: IOGSize maxCursorSize;
180: volatile unsigned char * cursorImages[ kIOFBNumCursorFrames ];
181: volatile unsigned char * cursorMasks[ kIOFBNumCursorFrames ];
182: volatile unsigned char * cursorSave;
183: unsigned int white;
184:
185: Point nextCursorLoc;
186: int nextCursorFrame;
187: void * vblInterrupt;
188: semaphore_t vblSemaphore;
189:
190: /* memory ranges */
191: volatile unsigned char * frameBuffer;
192: unsigned int totalWidth;
193: unsigned int rowBytes;
194: unsigned int bytesPerPixel;
195:
196: IOMemoryMap * vramMap;
197: IOByteCount vramMapOffset;
198: OSArray * userAccessRanges;
199: OSArray * engineAccessRanges;
200: IOBufferMemoryDescriptor * engineContext;
201: OSSet * fbNotifications;
202:
203: class IOFramebufferUserClient * serverConnect;
204: class IOFramebufferSharedUserClient * sharedConnect;
205:
206: bool opened;
207: bool closed;
208: bool clutValid;
209: bool currentMono;
210: bool needCursorService;
211: bool haveVBLService;
212: bool haveHWCursor;
213:
214: /* Reserved for future expansion. */
215: int _IOFramebuffer_reserved[8];
216:
217:
218: public:
219: static void initialize();
220:
221: virtual void disallowPowerDown ( void );
222: virtual void allowPowerDown ( void );
223: virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService* );
224: virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService* );
225: virtual IOReturn newUserClient( task_t owningTask,
226: void * security_id,
227: UInt32 type,
228: IOUserClient ** handler );
229:
230:
231: virtual void hideCursor( void );
232: virtual void showCursor( Point * cursorLoc, int frame );
233: virtual void moveCursor( Point * cursorLoc, int frame );
234:
235: virtual void setBrightness( int level );
236:
237: virtual void getBoundingRect ( Bounds ** bounds );
238:
239: virtual bool start( IOService * provider );
240:
241: virtual IOReturn open( void );
242:
243: virtual void close( void );
244:
245: virtual bool isConsoleDevice( void );
246:
247: virtual IOReturn setupForCurrentConfig( void );
248:
249: virtual bool serializeInfo( OSSerialize * s );
250: virtual bool setNumber( OSDictionary * dict, const char * key,
251: UInt32 number );
252:
253: IONotifier * addFramebufferNotification(
254: IOFramebufferNotificationHandler handler,
255: OSObject * self, void * ref);
256:
257: virtual IODeviceMemory * getApertureRange( IOPixelAperture aperture ) = 0;
258: virtual IODeviceMemory * getVRAMRange( void );
259:
260: protected:
261:
262: IOReturn deliverFramebufferNotification(
263: IOIndex event, void * info = 0 );
264:
265: #ifdef IOFRAMEBUFFER_PRIVATE
266: #include <IOKit/graphics/IOFramebufferPrivate.h>
267: #endif
268:
269: public:
270:
271: virtual IOReturn enableController( void );
272:
273: // List of pixel formats supported, null separated,
274: // doubly null terminated.
275: virtual const char * getPixelFormats( void ) = 0;
276:
277: // Array of supported display modes
278: virtual IOItemCount getDisplayModeCount( void ) = 0;
279: virtual IOReturn getDisplayModes( IODisplayModeID * allDisplayModes ) = 0;
280:
281: // Info about a display mode
282: virtual IOReturn getInformationForDisplayMode( IODisplayModeID displayMode,
283: IODisplayModeInformation * info ) = 0;
284:
285: // Mask of pixel formats available in mode and depth
286: virtual UInt64 getPixelFormatsForDisplayMode( IODisplayModeID displayMode,
287: IOIndex depth ) = 0;
288:
289: virtual IOReturn getPixelInformation(
290: IODisplayModeID displayMode, IOIndex depth,
291: IOPixelAperture aperture, IOPixelInformation * pixelInfo ) = 0;
292:
293: // Framebuffer info
294:
295: // Current display mode and depth
296: virtual IOReturn getCurrentDisplayMode( IODisplayModeID * displayMode,
297: IOIndex * depth ) = 0;
298:
299: // Set display mode and depth
300: virtual IOReturn setDisplayMode( IODisplayModeID displayMode,
301: IOIndex depth );
302:
303: // For pages
304: virtual IOReturn setApertureEnable( IOPixelAperture aperture,
305: IOOptionBits enable );
306:
307: // Display mode and depth for startup
308: virtual IOReturn setStartupDisplayMode( IODisplayModeID displayMode,
309: IOIndex depth );
310: virtual IOReturn getStartupDisplayMode( IODisplayModeID * displayMode,
311: IOIndex * depth );
312:
313: //// CLUTs
314:
315: virtual IOReturn setCLUTWithEntries( IOColorEntry * colors, UInt32 index,
316: UInt32 numEntries, IOOptionBits options );
317:
318: //// Gamma
319:
320: virtual IOReturn setGammaTable( UInt32 channelCount, UInt32 dataCount,
321: UInt32 dataWidth, void * data );
322:
323: //// Controller attributes
324:
325: virtual IOReturn setAttribute( IOSelect attribute, UInt32 value );
326: virtual IOReturn getAttribute( IOSelect attribute, UInt32 * value );
327:
328: //// Display mode timing information
329:
330: virtual IOReturn getTimingInfoForDisplayMode(
331: IODisplayModeID displayMode, IOTimingInformation * info );
332:
333: //// Connections
334:
335: virtual IOItemCount getConnectionCount( void );
336:
337: virtual IOReturn setAttributeForConnection( IOIndex connectIndex,
338: IOSelect attribute, UInt32 value );
339: virtual IOReturn getAttributeForConnection( IOIndex connectIndex,
340: IOSelect attribute, UInt32 * value );
341:
342: //// HW Cursors - straight from Marconi
343:
344: virtual bool convertCursorImage( void * cursorImage,
345: IOHardwareCursorDescriptor * description,
346: IOHardwareCursorInfo * cursor );
347:
348: virtual IOReturn setCursorImage( void * cursorImage );
349: virtual IOReturn setCursorState( SInt32 x, SInt32 y, bool visible );
350:
351: //// SW Cursors
352:
353: virtual void flushCursor( void );
354:
355: // Apple sensing
356:
357: virtual IOReturn getAppleSense( IOIndex connectIndex,
358: UInt32 * senseType,
359: UInt32 * primary,
360: UInt32 * extended,
361: UInt32 * displayType );
362:
363: virtual IOReturn connectFlags( IOIndex connectIndex,
364: IODisplayModeID displayMode, IOOptionBits * flags );
365:
366: //// IOLowLevelDDCSense
367:
368: virtual void setDDCClock( IOIndex connectIndex, UInt32 value );
369: virtual void setDDCData( IOIndex connectIndex, UInt32 value );
370: virtual bool readDDCClock( IOIndex connectIndex );
371: virtual bool readDDCData( IOIndex connectIndex );
372: virtual IOReturn enableDDCRaster( bool enable );
373:
374: //// IOHighLevelDDCSense
375:
376: virtual bool hasDDCConnect( IOIndex connectIndex );
377: virtual IOReturn getDDCBlock( IOIndex connectIndex, UInt32 blockNumber,
378: IOSelect blockType, IOOptionBits options,
379: UInt8 * data, IOByteCount * length );
380:
381: //// Interrupts
382:
383: // This is driven in the opposite direction to ndrv's ie. the base class
384: // registers a proc with the driver, and controls int generation with
385: // setInterruptState. Clients ask for serviceType.
386:
387: virtual IOReturn registerForInterruptType( IOSelect interruptType,
388: IOFBInterruptProc proc, OSObject * target, void * ref,
389: void ** interruptRef );
390: virtual IOReturn unregisterInterrupt( void * interruptRef );
391: virtual IOReturn setInterruptState( void * interruptRef, UInt32 state );
392:
393: virtual IOReturn getNotificationSemaphore( IOSelect interruptType,
394: semaphore_t * semaphore );
395: };
396:
397: #endif /* ! _IOKIT_IOFRAMEBUFFER_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.