| 1 |
/* |
| 2 |
* Copyright (C) 2009-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "CocoaDPMSSupport.h" |
| 10 |
|
| 11 |
#include "ServiceBroker.h" |
| 12 |
|
| 13 |
#include <CoreFoundation/CFNumber.h> |
| 14 |
#include <IOKit/IOKitLib.h> |
| 15 |
|
| 16 |
CCocoaDPMSSupport::CCocoaDPMSSupport() |
| 17 |
{ |
| 18 |
m_supportedModes.push_back(OFF); |
| 19 |
m_supportedModes.push_back(STANDBY); |
| 20 |
} |
| 21 |
|
| 22 |
bool CCocoaDPMSSupport::EnablePowerSaving(PowerSavingMode mode) |
| 23 |
{ |
| 24 |
// http://lists.apple.com/archives/Cocoa-dev/2007/Nov/msg00267.html |
| 25 |
// This is an unsupported system call that might kernel panic on PPC boxes |
| 26 |
// The reported OSX-PPC panic is unverified so we are going to enable this until |
| 27 |
// we find out which OSX-PPC boxes have problems, then add detect/disable for those boxes. |
| 28 |
io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler"); |
| 29 |
if (!r) |
| 30 |
return false; |
| 31 |
|
| 32 |
switch (mode) |
| 33 |
{ |
| 34 |
case OFF: |
| 35 |
case STANDBY: |
| 36 |
return (IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanTrue) == 0); |
| 37 |
default: |
| 38 |
return false; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
bool CCocoaDPMSSupport::DisablePowerSaving() |
| 43 |
{ |
| 44 |
// http://lists.apple.com/archives/Cocoa-dev/2007/Nov/msg00267.html |
| 45 |
// This is an unsupported system call that might kernel panic on PPC boxes |
| 46 |
// The reported OSX-PPC panic is unverified so we are going to enable this until |
| 47 |
// we find out which OSX-PPC boxes have problems, then add detect/disable for those boxes. |
| 48 |
io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler"); |
| 49 |
if (!r) |
| 50 |
return false; |
| 51 |
|
| 52 |
// Turn display on |
| 53 |
return (IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanFalse) == 0); |
| 54 |
} |