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_IODISPLAYWRANGLER_H 24#define _IOKIT_IODISPLAYWRANGLER_H 25 26#include <IOKit/IOService.h> 27#define IOFRAMEBUFFER_PRIVATE 28#include <IOKit/graphics/IOFramebuffer.h> 29#include <IOKit/graphics/IODisplay.h> 30 31class IODisplayWrangler : public IOService 32{ 33 OSDeclareDefaultStructors( IODisplayWrangler ); 34 35private: 36 bool fOpen; 37 IOLock * fMatchingLock; 38 OSSet * fFramebuffers; 39 OSSet * fDisplays; 40 41 // from control panel: number of idle minutes before going off 42 UInt32 fMinutesToDim; 43 // false: use minutesToDim unless in emergency situation 44 bool fDimCaptured; 45 bool fAnnoyed; 46 47 unsigned long fPendingPowerState; 48 49 // ignore activity until time 50 AbsoluteTime fIdleUntil; 51 // annoyed wake until time 52 AbsoluteTime fAnnoyanceUntil; 53 54 AbsoluteTime fDimInterval; 55 AbsoluteTime fSettingsChanged; 56 AbsoluteTime fOffInterval[2]; 57 58 AbsoluteTime fPowerStateChangeTime; 59 60private: 61 62 virtual void initForPM( void ); 63 virtual IOReturn setAggressiveness( unsigned long, unsigned long ); 64 virtual bool activityTickle( unsigned long, unsigned long ); 65 virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService* whatDevice ); 66 67 virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags domainState ); 68 69 static bool _displayHandler( void * target, void * ref, 70 IOService * newService, IONotifier * notifier ); 71 static bool _displayConnectHandler( void * target, void * ref, 72 IOService * newService, IONotifier * notifier ); 73 74 virtual bool displayHandler( OSSet * set, IODisplay * newDisplay); 75 virtual bool displayConnectHandler( void * ref, IODisplayConnect * connect); 76 77 virtual IODisplayConnect * getDisplayConnect( 78 IOFramebuffer * fb, IOIndex connect ); 79 80 virtual IOReturn getConnectFlagsForDisplayMode( 81 IODisplayConnect * connect, 82 IODisplayModeID mode, UInt32 * flags ); 83 84public: 85 86 static bool serverStart(void); 87 virtual bool start(IOService * provider); 88 89 static bool makeDisplayConnects( IOFramebuffer * fb ); 90 static void destroyDisplayConnects( IOFramebuffer * fb ); 91 static void activityChange( IOFramebuffer * fb ); 92 static unsigned long getDisplaysPowerState(void); 93 94 virtual OSObject * copyProperty( const char * aKey) const; 95 96 static IOReturn getFlagsForDisplayMode( 97 IOFramebuffer * fb, 98 IODisplayModeID mode, UInt32 * flags ); 99 100 // Adaptive Dimming methods 101 virtual SInt32 nextIdleTimeout(AbsoluteTime currentTime, 102 AbsoluteTime lastActivity, unsigned int powerState); 103 104public: 105 virtual IOReturn setProperties( OSObject * properties ); 106 107}; 108 109void IODisplayUpdateNVRAM( IOService * entry, OSData * property ); 110 111#endif /* _IOKIT_IODISPLAYWRANGLER_H */ 112