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