Skip to content

Instantly share code, notes, and snippets.

@qwerty12
Created August 7, 2013 21:16
Show Gist options
  • Save qwerty12/6178778 to your computer and use it in GitHub Desktop.
Save qwerty12/6178778 to your computer and use it in GitHub Desktop.
Based on eDio and medvegiypreved's work here: https://wiki.archlinux.org/index.php/Backlight#Backlight_PWM_modulation_frequency_.28Intel_i915_only.29 and EmlyDinesh's code to write to the memory address DON'T USE THIS AS-IS!
#include <IOKit/IOService.h>
class IntelPWMManipulation : public IOService
{
OSDeclareDefaultStructors(IntelPWMManipulation);
public:
bool start(IOService *provider);
};
OSDefineMetaClassAndStructors(IntelPWMManipulation, IOService)
bool IntelPWMManipulation::start(IOService *provider)
{
if (!IOService::start(provider))
return false;
IORegistryEntry *IGPU = IORegistryEntry::fromPath("IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/IGPU");
if (IGPU) {
IOService *igpuService = OSDynamicCast(IOService, IGPU);
if (igpuService && igpuService->getDeviceMemoryCount() > 0) {
UInt32 val;
IOMemoryDescriptor *igpuMmio = igpuService->getDeviceMemoryWithIndex(0);
igpuMmio->readBytes(0xC8254, &val, sizeof(val));
printf("0x%X\n", val);
val = 0x7a107a1;
igpuMmio->writeBytes(0xC8254, &val, sizeof(val));
}
IGPU->release();
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment