]> git.saurik.com Git - apple/xnu.git/blame - iokit/Families/IOGraphics/IOBootFramebuffer.cpp
xnu-124.13.tar.gz
[apple/xnu.git] / iokit / Families / IOGraphics / IOBootFramebuffer.cpp
CommitLineData
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 * Boot video dumb frambuffer shim
24 */
25
26#include "IOBootFramebuffer.h"
27
28enum { kTheDisplayMode = 10 };
29
30/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
31
32#undef super
33#define super IOFramebuffer
34
35OSDefineMetaClassAndStructors(IOBootFramebuffer, IOFramebuffer)
36
37/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
38
39IOService * IOBootFramebuffer::probe( IOService * provider,
40 SInt32 * score )
41{
42 PE_Video bootDisplay;
43 IOService * ret = 0;
44 IOReturn err;
45
46 do {
47
48 if( !provider->getProperty("AAPL,boot-display"))
49 continue;
50
51 err = getPlatform()->getConsoleInfo( &bootDisplay );
52 if( err || (bootDisplay.v_baseAddr == 0))
53 continue;
54
55 if (false == super::probe( provider, score ))
56 continue;
57
58 *score = 0;
59 ret = this; // Success
60
61 } while( false);
62
63 return( ret);
64}
65
66
67const char * IOBootFramebuffer::getPixelFormats( void )
68{
69 const char * ret;
70 PE_Video bootDisplay;
71
72 getPlatform()->getConsoleInfo( &bootDisplay);
73
74 switch( bootDisplay.v_depth) {
75 case 8:
76 default:
77 ret = IO8BitIndexedPixels;
78 break;
79 case 15:
80 case 16:
81 ret = IO16BitDirectPixels;
82 break;
83 case 24:
84 case 32:
85 ret = IO32BitDirectPixels;
86 break;
87 }
88
89 return( ret);
90}
91
92IOItemCount IOBootFramebuffer::getDisplayModeCount( void )
93{
94 return( 1);
95}
96
97IOReturn IOBootFramebuffer::getDisplayModes(
98 IODisplayModeID * allDisplayModes )
99{
100
101 *allDisplayModes = kTheDisplayMode;
102 return( kIOReturnSuccess);
103}
104
105IOReturn IOBootFramebuffer::getInformationForDisplayMode(
106 IODisplayModeID /* displayMode */,
107 IODisplayModeInformation * info )
108{
109 PE_Video bootDisplay;
110
111 getPlatform()->getConsoleInfo( &bootDisplay);
112
113 bzero( info, sizeof( *info));
114
115 info->maxDepthIndex = 0;
116 info->nominalWidth = bootDisplay.v_width;
117 info->nominalHeight = bootDisplay.v_height;
118 info->refreshRate = 75 << 16;
119
120 return( kIOReturnSuccess);
121}
122
123UInt64 IOBootFramebuffer::getPixelFormatsForDisplayMode(
124 IODisplayModeID /* displayMode */, IOIndex /* depth */ )
125{
126 return( 1);
127}
128
129IOReturn IOBootFramebuffer::getPixelInformation(
130 IODisplayModeID displayMode, IOIndex depth,
131 IOPixelAperture aperture, IOPixelInformation * info )
132{
133 PE_Video bootDisplay;
134
135 if( aperture || depth || (displayMode != kTheDisplayMode) )
136 return( kIOReturnUnsupportedMode);
137
138 getPlatform()->getConsoleInfo( &bootDisplay);
139
140 bzero( info, sizeof( *info));
141
142 info->activeWidth = bootDisplay.v_width;
143 info->activeHeight = bootDisplay.v_height;
144 info->bytesPerRow = bootDisplay.v_rowBytes & 0x7fff;
145 info->bytesPerPlane = 0;
146
147 switch( bootDisplay.v_depth ) {
148 case 8:
149 default:
150 strcpy(info->pixelFormat, IO8BitIndexedPixels );
151 info->pixelType = kIOCLUTPixels;
152 info->componentMasks[0] = 0xff;
153 info->bitsPerPixel = 8;
154 info->componentCount = 1;
155 info->bitsPerComponent = 8;
156 break;
157 case 15:
158 case 16:
159 strcpy(info->pixelFormat, IO16BitDirectPixels );
160 info->pixelType = kIORGBDirectPixels;
161 info->componentMasks[0] = 0x7c00;
162 info->componentMasks[1] = 0x03e0;
163 info->componentMasks[2] = 0x001f;
164 info->bitsPerPixel = 16;
165 info->componentCount = 3;
166 info->bitsPerComponent = 5;
167 break;
168 case 24:
169 case 32:
170 strcpy(info->pixelFormat, IO32BitDirectPixels );
171 info->pixelType = kIORGBDirectPixels;
172 info->componentMasks[0] = 0x00ff0000;
173 info->componentMasks[1] = 0x0000ff00;
174 info->componentMasks[2] = 0x000000ff;
175 info->bitsPerPixel = 32;
176 info->componentCount = 3;
177 info->bitsPerComponent = 8;
178 break;
179 }
180
181 return( kIOReturnSuccess);
182}
183
184IOReturn IOBootFramebuffer::getCurrentDisplayMode(
185 IODisplayModeID * displayMode, IOIndex * depth )
186{
187 if( displayMode)
188 *displayMode = kTheDisplayMode;
189 if( depth)
190 *depth = 0;
191
192 return( kIOReturnSuccess);
193}
194
195IODeviceMemory * IOBootFramebuffer::getApertureRange( IOPixelAperture aper )
196{
197 IOReturn err;
198 IOPixelInformation info;
199 IOByteCount bytes;
200 PE_Video bootDisplay;
201
202 getPlatform()->getConsoleInfo( &bootDisplay);
203
204 err = getPixelInformation( kTheDisplayMode, 0, aper,
205 &info );
206 if( err)
207 return( 0 );
208
209 bytes = (info.bytesPerRow * info.activeHeight) + 128;
210
211 return( IODeviceMemory::withRange( bootDisplay.v_baseAddr, bytes ));
212}
213
214bool IOBootFramebuffer::isConsoleDevice( void )
215{
216 return( (0 != getProvider()->getProperty("AAPL,boot-display")) );
217}
218
219IOReturn IOBootFramebuffer::setGammaTable( UInt32 channelCount,
220 UInt32 dataCount, UInt32 dataWidth, void * data )
221{
222 return( kIOReturnSuccess );
223}
224
225IOReturn IOBootFramebuffer::setCLUTWithEntries(
226 IOColorEntry * colors, UInt32 index, UInt32 numEntries,
227 IOOptionBits options )
228{
229 return( kIOReturnSuccess );
230}