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_IODISPLAY_H␊ |
24 | #define _IOKIT_IODISPLAY_H␊ |
25 | ␊ |
26 | #include <IOKit/IOService.h>␊ |
27 | #include <IOKit/graphics/IOFramebuffer.h>␊ |
28 | ␊ |
29 | extern const OSSymbol * gIODisplayParametersKey;␊ |
30 | extern const OSSymbol * gIODisplayGUIDKey;␊ |
31 | ␊ |
32 | extern const OSSymbol * gIODisplayValueKey;␊ |
33 | extern const OSSymbol * gIODisplayMinValueKey;␊ |
34 | extern const OSSymbol * gIODisplayMaxValueKey;␊ |
35 | ␊ |
36 | extern const OSSymbol * gIODisplayContrastKey;␊ |
37 | extern const OSSymbol * gIODisplayBrightnessKey;␊ |
38 | extern const OSSymbol * gIODisplayLinearBrightnessKey;␊ |
39 | extern const OSSymbol * gIODisplayUsableLinearBrightnessKey;␊ |
40 | extern const OSSymbol * gIODisplayBrightnessFadeKey;␊ |
41 | extern const OSSymbol * gIODisplayHorizontalPositionKey;␊ |
42 | extern const OSSymbol * gIODisplayHorizontalSizeKey;␊ |
43 | extern const OSSymbol * gIODisplayVerticalPositionKey;␊ |
44 | extern const OSSymbol * gIODisplayVerticalSizeKey;␊ |
45 | extern const OSSymbol * gIODisplayTrapezoidKey;␊ |
46 | extern const OSSymbol * gIODisplayPincushionKey;␊ |
47 | extern const OSSymbol * gIODisplayParallelogramKey;␊ |
48 | extern const OSSymbol * gIODisplayRotationKey;␊ |
49 | extern const OSSymbol * gIODisplayOverscanKey;␊ |
50 | extern const OSSymbol * gIODisplayVideoBestKey;␊ |
51 | extern const OSSymbol * gIODisplaySelectedColorModeKey;␊ |
52 | ␊ |
53 | extern const OSSymbol * gIODisplayRedGammaScaleKey;␊ |
54 | extern const OSSymbol * gIODisplayGreenGammaScaleKey;␊ |
55 | extern const OSSymbol * gIODisplayBlueGammaScaleKey;␊ |
56 | extern const OSSymbol * gIODisplayGammaScaleKey;␊ |
57 | ␊ |
58 | extern const OSSymbol * gIODisplayParametersTheatreModeKey;␊ |
59 | extern const OSSymbol * gIODisplayParametersTheatreModeWindowKey;␊ |
60 | ␊ |
61 | extern const OSSymbol * gIODisplayMCCSVersionKey;␊ |
62 | extern const OSSymbol * gIODisplayTechnologyTypeKey;␊ |
63 | extern const OSSymbol * gIODisplayUsageTimeKey;␊ |
64 | extern const OSSymbol * gIODisplayFirmwareLevelKey;␊ |
65 | ␊ |
66 | extern const OSSymbol * gIODisplaySpeakerVolumeKey;␊ |
67 | extern const OSSymbol * gIODisplaySpeakerSelectKey;␊ |
68 | extern const OSSymbol * gIODisplayMicrophoneVolumeKey;␊ |
69 | extern const OSSymbol * gIODisplayAmbientLightSensorKey;␊ |
70 | extern const OSSymbol * gIODisplayAudioMuteAndScreenBlankKey;␊ |
71 | extern const OSSymbol * gIODisplayAudioTrebleKey;␊ |
72 | extern const OSSymbol * gIODisplayAudioBassKey;␊ |
73 | extern const OSSymbol * gIODisplayAudioBalanceLRKey;␊ |
74 | extern const OSSymbol * gIODisplayAudioProcessorModeKey;␊ |
75 | extern const OSSymbol * gIODisplayPowerModeKey;␊ |
76 | extern const OSSymbol * gIODisplayManufacturerSpecificKey;␊ |
77 | ␊ |
78 | extern const OSSymbol * gIODisplayPowerStateKey;␊ |
79 | extern const OSSymbol * gIODisplayControllerIDKey;␊ |
80 | extern const OSSymbol * gIODisplayCapabilityStringKey;␊ |
81 | ␊ |
82 | extern const OSSymbol * gIODisplayParametersCommitKey;␊ |
83 | extern const OSSymbol * gIODisplayParametersDefaultKey;␊ |
84 | extern const OSSymbol * gIODisplayParametersFlushKey;␊ |
85 | ␊ |
86 | extern const OSSymbol * gIODisplayFadeTime1Key;␊ |
87 | extern const OSSymbol * gIODisplayFadeTime2Key;␊ |
88 | extern const OSSymbol * gIODisplayFadeTime3Key;␊ |
89 | extern const OSSymbol * gIODisplayFadeStyleKey;␊ |
90 | ␊ |
91 | extern UInt32 gIODisplayFadeTime1;␊ |
92 | extern UInt32 gIODisplayFadeTime2;␊ |
93 | extern UInt32 gIODisplayFadeTime3;␊ |
94 | extern UInt32 gIODisplayFadeStyle;␊ |
95 | ␊ |
96 | enum {␊ |
97 | kIODisplayNumPowerStates = 4,␊ |
98 | kIODisplayMaxPowerState = kIODisplayNumPowerStates - 1␊ |
99 | };␊ |
100 | ␊ |
101 | // these are the private instance variables for power management␊ |
102 | struct DisplayPMVars␊ |
103 | {␊ |
104 | UInt32 currentState;␊ |
105 | // highest state number normally, lowest usable state in emergency␊ |
106 | unsigned long maxState;␊ |
107 | // true if the display has had power lowered due to user inactivity␊ |
108 | bool displayIdle;␊ |
109 | };␊ |
110 | ␊ |
111 | class IODisplayConnect : public IOService␊ |
112 | {␊ |
113 | OSDeclareDefaultStructors(IODisplayConnect)␊ |
114 | ␊ |
115 | private:␊ |
116 | IOIndex connection;␊ |
117 | ␊ |
118 | protected:␊ |
119 | /* Reserved for future use. (Internal use only) */␊ |
120 | struct ExpansionData { };␊ |
121 | ␊ |
122 | /* Reserved for future use. (Internal use only) */␊ |
123 | ExpansionData * reserved;␊ |
124 | ␊ |
125 | public:␊ |
126 | virtual bool initWithConnection( IOIndex connection );␊ |
127 | virtual IOFramebuffer * getFramebuffer( void );␊ |
128 | virtual IOIndex getConnection( void );␊ |
129 | virtual IOReturn getAttributeForConnection( IOSelect selector, uintptr_t * value );␊ |
130 | virtual IOReturn setAttributeForConnection( IOSelect selector, uintptr_t value );␊ |
131 | virtual void joinPMtree ( IOService * driver );␊ |
132 | };␊ |
133 | ␊ |
134 | class IODisplay : public IOService␊ |
135 | {␊ |
136 | OSDeclareAbstractStructors(IODisplay)␊ |
137 | ␊ |
138 | public:␊ |
139 | static void initialize( void );␊ |
140 | ␊ |
141 | protected:␊ |
142 | // used to query the framebuffer controller␊ |
143 | IODisplayConnect * fConnection;␊ |
144 | class IODisplayParameterHandler * fParameterHandler;␊ |
145 | void * __resv;␊ |
146 | IONotifier * fNotifier;␊ |
147 | ␊ |
148 | // pointer to protected instance variables for power management␊ |
149 | struct IODisplayPMVars * fDisplayPMVars;␊ |
150 | ␊ |
151 | // reserved for future expansion␊ |
152 | void * _IODisplay_reserved[32];␊ |
153 | ␊ |
154 | public:␊ |
155 | virtual IOService * probe( IOService * provider,␊ |
156 | SInt32 * score );␊ |
157 | ␊ |
158 | virtual bool start( IOService * provider );␊ |
159 | virtual void stop( IOService * provider );␊ |
160 | virtual void free();␊ |
161 | ␊ |
162 | virtual IODisplayConnect * getConnection( void );␊ |
163 | ␊ |
164 | virtual IOReturn getConnectFlagsForDisplayMode(␊ |
165 | IODisplayModeID mode, UInt32 * flags );␊ |
166 | ␊ |
167 | virtual IOReturn getGammaTableByIndex(␊ |
168 | UInt32 * channelCount, UInt32 * dataCount,␊ |
169 | UInt32 * dataWidth, void ** data );␊ |
170 | ␊ |
171 | virtual IOReturn readFramebufferEDID( void );␊ |
172 | ␊ |
173 | // ␊ |
174 | virtual IOReturn framebufferEvent( IOFramebuffer * framebuffer, ␊ |
175 | IOIndex event, void * info );␊ |
176 | ␊ |
177 | // parameter setting␊ |
178 | virtual IOReturn setProperties( OSObject * properties );␊ |
179 | virtual bool setForKey( OSDictionary * params, const OSSymbol * key,␊ |
180 | SInt32 value, SInt32 min, SInt32 max );␊ |
181 | ␊ |
182 | static bool addParameter( OSDictionary * params, const OSSymbol * paramName, SInt32 min, SInt32 max );␊ |
183 | static bool setParameter( OSDictionary * params, const OSSymbol * paramName, SInt32 value );␊ |
184 | static OSDictionary * getIntegerRange( OSDictionary * params, const OSSymbol * sym,␊ |
185 | SInt32 * value, SInt32 * min, SInt32 * max );␊ |
186 | ␊ |
187 | // low level set/get␊ |
188 | virtual bool doIntegerSet( OSDictionary * params,␊ |
189 | const OSSymbol * paramName, UInt32 value );␊ |
190 | virtual bool doDataSet( const OSSymbol * paramName, OSData * value );␊ |
191 | virtual bool doUpdate( void );␊ |
192 | ␊ |
193 | // power management methods␊ |
194 | virtual IOReturn setPowerState( unsigned long, IOService * );␊ |
195 | virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags );␊ |
196 | virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags );␊ |
197 | virtual unsigned long powerStateForDomainState( IOPMPowerFlags );␊ |
198 | ␊ |
199 | // ␊ |
200 | virtual void initPowerManagement( IOService * provider);␊ |
201 | virtual void dropOneLevel( void );␊ |
202 | virtual void makeDisplayUsable( void );␊ |
203 | void setDisplayPowerState(unsigned long state);␊ |
204 | ␊ |
205 | private:␊ |
206 | OSMetaClassDeclareReservedUnused(IODisplay, 0);␊ |
207 | OSMetaClassDeclareReservedUnused(IODisplay, 1);␊ |
208 | OSMetaClassDeclareReservedUnused(IODisplay, 2);␊ |
209 | OSMetaClassDeclareReservedUnused(IODisplay, 3);␊ |
210 | OSMetaClassDeclareReservedUnused(IODisplay, 4);␊ |
211 | OSMetaClassDeclareReservedUnused(IODisplay, 5);␊ |
212 | OSMetaClassDeclareReservedUnused(IODisplay, 6);␊ |
213 | OSMetaClassDeclareReservedUnused(IODisplay, 7);␊ |
214 | OSMetaClassDeclareReservedUnused(IODisplay, 8);␊ |
215 | OSMetaClassDeclareReservedUnused(IODisplay, 9);␊ |
216 | OSMetaClassDeclareReservedUnused(IODisplay, 10);␊ |
217 | OSMetaClassDeclareReservedUnused(IODisplay, 11);␊ |
218 | OSMetaClassDeclareReservedUnused(IODisplay, 12);␊ |
219 | OSMetaClassDeclareReservedUnused(IODisplay, 13);␊ |
220 | OSMetaClassDeclareReservedUnused(IODisplay, 14);␊ |
221 | OSMetaClassDeclareReservedUnused(IODisplay, 15);␊ |
222 | OSMetaClassDeclareReservedUnused(IODisplay, 16);␊ |
223 | OSMetaClassDeclareReservedUnused(IODisplay, 17);␊ |
224 | OSMetaClassDeclareReservedUnused(IODisplay, 18);␊ |
225 | OSMetaClassDeclareReservedUnused(IODisplay, 19);␊ |
226 | ␊ |
227 | private:␊ |
228 | static IOReturn _framebufferEvent( OSObject * self, void * ref,␊ |
229 | IOFramebuffer *framebuffer, IOIndex event, void * info );␊ |
230 | ␊ |
231 | ␉void searchParameterHandlers(IORegistryEntry * entry);␊ |
232 | bool addParameterHandler( IODisplayParameterHandler * parameterHandler );␊ |
233 | bool removeParameterHandler( IODisplayParameterHandler * parameterHandler );␊ |
234 | static bool updateNumber( OSDictionary * params, const OSSymbol * key, SInt32 value );␊ |
235 | };␊ |
236 | ␊ |
237 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
238 | ␊ |
239 | class IOBacklightDisplay : public IODisplay␊ |
240 | {␊ |
241 | OSDeclareDefaultStructors(IOBacklightDisplay)␊ |
242 | ␊ |
243 | protected:␊ |
244 | // User preferred brightness level␊ |
245 | SInt32 fCurrentUserBrightness;␊ |
246 | SInt32 fCurrentBrightness;␊ |
247 | UInt32 fCurrentPowerState;␊ |
248 | SInt32 fMinBrightness;␊ |
249 | SInt32 fMaxBrightness;␊ |
250 | UInt16 fMaxBrightnessLevel[kIODisplayNumPowerStates];␊ |
251 | ␊ |
252 | public:␊ |
253 | virtual IOService * probe( IOService *, SInt32 * );␊ |
254 | virtual void stop( IOService * provider );␊ |
255 | virtual IOReturn setPowerState( unsigned long, IOService * );␊ |
256 | virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags );␊ |
257 | virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags );␊ |
258 | virtual unsigned long powerStateForDomainState( IOPMPowerFlags );␊ |
259 | ␊ |
260 | // ␊ |
261 | virtual void initPowerManagement( IOService * );␊ |
262 | ␊ |
263 | public:␊ |
264 | virtual bool doIntegerSet( OSDictionary * params,␊ |
265 | const OSSymbol * paramName, UInt32 value );␊ |
266 | virtual bool doUpdate( void );␊ |
267 | virtual void makeDisplayUsable( void );␊ |
268 | virtual bool setBrightness( SInt32 value );␊ |
269 | ␊ |
270 | private:␊ |
271 | void handlePMSettingCallback(const OSSymbol *, OSObject *, uintptr_t);␊ |
272 | ␊ |
273 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 0);␊ |
274 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 1);␊ |
275 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 2);␊ |
276 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 3);␊ |
277 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 4);␊ |
278 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 5);␊ |
279 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 6);␊ |
280 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 7);␊ |
281 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 8);␊ |
282 | OSMetaClassDeclareReservedUnused(IOBacklightDisplay, 9);␊ |
283 | };␊ |
284 | ␊ |
285 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
286 | ␊ |
287 | class IODisplayParameterHandler : public IOService␊ |
288 | {␊ |
289 | OSDeclareDefaultStructors(IODisplayParameterHandler)␊ |
290 | ␊ |
291 | public:␊ |
292 | virtual bool setDisplay( IODisplay * display ) = 0;␊ |
293 | virtual bool doIntegerSet( OSDictionary * params,␊ |
294 | const OSSymbol * paramName, UInt32 value ) = 0;␊ |
295 | virtual bool doDataSet( const OSSymbol * paramName, OSData * value ) = 0;␊ |
296 | virtual bool doUpdate( void ) = 0;␊ |
297 | ␊ |
298 | private:␊ |
299 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 0);␊ |
300 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 1);␊ |
301 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 2);␊ |
302 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 3);␊ |
303 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 4);␊ |
304 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 5);␊ |
305 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 6);␊ |
306 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 7);␊ |
307 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 8);␊ |
308 | OSMetaClassDeclareReservedUnused(IODisplayParameterHandler, 9);␊ |
309 | };␊ |
310 | ␊ |
311 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
312 | ␊ |
313 | #endif /* ! _IOKIT_IODISPLAY_H */␊ |
314 | ␊ |
315 | |