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_IOGRAPHICSPRIVATE_H
24#define _IOKIT_IOGRAPHICSPRIVATE_H
25
26#include <mach/vm_param.h>
27#include <libkern/version.h>
28#include <libkern/OSDebug.h>
29#include <IOKit/graphics/IOGraphicsTypesPrivate.h>
30
31#if 0
32#warning **LOGS**
33#define RLOG 1
34#define DEBG(name, fmt, args...)         \
35do {                                    \
36    AbsoluteTime    now;                \
37    UInt64          nano;               \
38    AbsoluteTime_to_scalar(&now) = mach_absolute_time();                \
39    absolutetime_to_nanoseconds(now, &nano);                            \
40    IOLog("%08d [%s]::", (uint32_t) (nano / 1000000ULL), name);           \
41    IOLog("%s", __FUNCTION__);          \
42    IOLog(fmt, ## args);                \
43    kprintf("%08d [%s]::", (uint32_t) (nano / 1000000ULL), name);         \
44    kprintf("%s", __FUNCTION__);        \
45    kprintf(fmt, ## args);              \
46} while( false )
47
48#else
49#define DEBG(idx, fmt, args...)  {}
50#endif
51
52#if 0
53
54#warning **LOGS**
55#define RLOG1 1
56#define DEBG1(name, fmt, args...)                \
57do {                                    \
58    AbsoluteTime    now;                \
59    UInt64          nano;               \
60    AbsoluteTime_to_scalar(&now) = mach_absolute_time();                \
61    absolutetime_to_nanoseconds( now, &nano );                          \
62    IOLog("%08d [%s]::", (uint32_t) (nano / 1000000ULL), name);           \
63    IOLog("%s", __FUNCTION__);          \
64    IOLog(fmt, ## args);                \
65    kprintf("%08d [%s]::", (uint32_t) (nano / 1000000ULL), name);           \
66    kprintf("%s", __FUNCTION__);          \
67    kprintf(fmt, ## args);                \
68} while( false )
69
70#else
71#define DEBG1(idx, fmt, args...)  {}
72#endif
73
74#if 0
75
76#warning **LOGS**
77#define DEBG2(name, fmt, args...)                \
78do {                                    \
79    AbsoluteTime    now;                \
80    UInt64          nano;               \
81    AbsoluteTime_to_scalar(&now) = mach_absolute_time();                \
82    absolutetime_to_nanoseconds( now, &nano );                          \
83    IOLog("%08d [%s]::", (uint32_t) (nano / 1000000ULL), name);           \
84    IOLog("%s", __FUNCTION__);          \
85    IOLog(fmt, ## args);                \
86    kprintf("%08d [%s]::", (uint32_t) (nano / 1000000ULL), name);           \
87    kprintf("%s", __FUNCTION__);          \
88    kprintf(fmt, ## args);                \
89} while( false )
90
91#else
92#define DEBG2(idx, fmt, args...)  {}
93#endif
94
95#define STOREINC(_ptr_, _data_, _type_) {   \
96        *((_type_ *)(_ptr_)) = _data_;                                  \
97        _ptr_ = (typeof(_ptr_)) (((char *) (_ptr_)) + sizeof(_type_));  \
98    }
99
100// blue actual:0x00426bad gamma:0x00648cc3 bootx:0x00bfbfbf
101#define kIOFBBootGrayValue              0x00bfbfbf
102#define kIOFBGrayValue                  0x00000000
103
104#ifndef kAppleAudioVideoJackStateKey
105#define kAppleAudioVideoJackStateKey    "AppleAudioVideoJackState"
106#endif
107#ifndef kIOPMIsPowerManagedKey
108#define kIOPMIsPowerManagedKey          "IOPMIsPowerManaged"
109#endif
110#ifndef kIOAGPCommandValueKey
111#define kIOAGPCommandValueKey           "IOAGPCommandValue"
112#endif
113#ifndef kAppleClamshellStateKey
114#define kAppleClamshellStateKey         "AppleClamshellState"
115#endif
116#ifndef kIOFBWaitCursorFramesKey
117#define kIOFBWaitCursorFramesKey        "IOFBWaitCursorFrames"
118#endif
119#ifndef kIOFBWaitCursorPeriodKey
120#define kIOFBWaitCursorPeriodKey        "IOFBWaitCursorPeriod"
121#endif
122
123#ifndef kIOUserClientSharedInstanceKey
124#define kIOUserClientSharedInstanceKey  "IOUserClientSharedInstance"
125#endif
126
127#ifndef kIOHibernateOptionsKey
128#define kIOHibernateOptionsKey      "IOHibernateOptions"
129#endif
130
131#ifndef kIOHibernateGfxStatusKey
132#define kIOHibernateGfxStatusKey    "IOHibernateGfxStatus"
133#endif
134
135#ifndef kIOMessageSystemPagingOff
136#define kIOMessageSystemPagingOff       iokit_common_msg(0x255)
137#endif
138
139extern "C" ppnum_t pmap_find_phys(pmap_t map, addr64_t va);
140
141extern "C" vm_map_t IOPageableMapForAddress( vm_address_t address );
142
143extern "C" IOReturn IOGetHardwareClamshellState( IOOptionBits * result );
144
145extern bool                   gIOGraphicsSystemPower;
146extern bool                   gIOFBSystemPower;
147extern IOOptionBits           gIOFBCurrentClamshellState;
148extern const class OSSymbol * gIOFramebufferKey;
149extern class OSData *         gIOFBZero32Data;
150extern int32_t                gIOFBHaveBacklight;
151extern const OSSymbol *       gIOFBPMSettingDisplaySleepUsesDimKey;
152
153#if __ppc__
154extern "C" void bcopy_nc( void * from, void * to, UInt32 l );
155extern "C" void bzero_nc( void * p, UInt32 l );
156#else
157inline void bcopy_nc( void * from, void * to, UInt32 l) { bcopy( from, to, l ); }
158inline void bzero_nc( void * p, UInt32 l )              { bzero( p, l ); }
159#endif
160
161#if VERSION_MAJOR < 9
162#define getPowerState() pm_vars->myCurrentState
163#endif
164
165#define thisIndex               _IOFramebuffer_reserved[4]
166
167extern uint32_t gIOGDebugFlags;
168enum
169{
170	kIOGDbgLidOpen         = 0x00000001,
171	kIOGDbgVBLThrottle     = 0x00000002,
172	kIOGDbgK59Mode         = 0x00000004,
173	kIOGDbgDumbPanic       = 0x00000008,
174	kIOGDbgVBLDrift        = 0x00000010,
175	kIOGDbgForceBrightness = 0x00000020,
176};
177
178#ifndef kIOScreenLockStateKey
179
180#define IOHIB_PREVIEW_V0	1
181
182enum { kIOPreviewImageCount = 1 };
183
184struct hibernate_preview_t
185{
186    uint32_t  depth;      	// Pixel Depth
187    uint32_t  width;      	// Width
188    uint32_t  height;     	// Height
189};
190typedef struct hibernate_preview_t hibernate_preview_t;
191
192#define kIOScreenLockStateKey      "IOScreenLockState"
193
194#endif /* ! kIOScreenLockStateKey */
195
196// these are the private instance variables for power management
197struct IODisplayPMVars
198{
199    UInt32              currentState;
200    // highest state number normally, lowest usable state in emergency
201    unsigned long       maxState;
202    unsigned long       minDimState;
203    // true if the display has had power lowered due to user inactivity
204    bool                displayIdle;
205};
206
207#endif /* ! _IOKIT_IOGRAPHICSPRIVATE_H */
208
209