Skip to content

kambala-decapitator/GmuxBrightness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GmuxBrightness

Restore broken screen brightness control as well as wake from sleep on old macbooks that use GMUX controller.

The app is a menubar icon displaying current brightness level. It has been tested only on MacBookPro6,2 running Ventura OCLP, but I believe it should work on any pre-retina Intel macbook.

Requirements

  1. Old macbook with broken screen brightness control (e.g. broken dGPU)
  2. macOS 11+ (via OCLP)
  3. Chipsec helper driver, available in versions until 1.11.0
  4. Karabiner

Running

Configure Karabiner

It's far from easy to capture the standard screen brightness hotkeys in code, so we'll use Karabiner as a helper. Go to its Settings - Function Keys and map keys as follows:

  • f1 -> apple_display_brightness_decrement
  • f2 -> apple_display_brightness_increment

These keys are in the Others category:

Run the app

First, add your terminal app (the standard Terminal, iTerm2, etc.) to System Settings - Privacy & Security - Accessibility. If you don't do it beforehand, the first time you run the app you'll be asked to do so, and after enabling you'll have to restart the app.

Then, run the app passing path to the Chipsec helper driver kext:

sudo /path/to/GmuxBrightness/binary /path/to/chipsec/driver/kext

Building

Chipsec helper driver

Xcode project is located at drivers/osx directory. From the command line it can be built as:

# assuming that CWD is chipsec root directory
xcodebuild -project drivers/osx/chipsec.xcodeproj -target chipsec

The built kext can be found at drivers/osx/build/Release/chipsec.kext.

The first time the kext is attempted to be loaded, macOS will ask you to reboot. So load it manually and reboot:

sudo kmutil load -p drivers/osx/build/Release/chipsec.kext

The app

This is a standard Xcode project, a Cocoa application. It can be built with Xcode >= 14. The only thing preventing it to be built with Xcode < 14 is the usage of Info.plist generation feature. To build from command line:

xcodebuild -target GmuxBrightness

Motivation

My MacBookPro6,2 (15'' MBP mid-2010) has broken dGPU, so I've disabled it completely. However, this broke screen brightness control on macOS >= 10.13, as the GMUX controller is tied to dGPU. Also, when macbook wakes from sleep, it doesn't know how to restore screen brightness, so you end up with a black screen, and the only way is to reboot.

Interestingly though, on 10.10 screen brightness control works fine. Probably it works on all macOS < 10.13, as the brightness driver has been changed only in 10.13.

Other workarounds

I've tested these options only on macOS 10.13 (High Sierra) and 13 (Ventura). But I know that the brightness also doesn't work on all macOS >= 11.

macOS 10.13

There's a very easy fix: simply copy AppleMuxControl.kext from macOS 10.12.

Any macOS

You can use Chipsec to work with I/O ports. Last version where it works is 1.10.4. To restore this functionality in 1.10.5 & 1.10.6, use this patch.

# obtain max brightness value
sudo ./chipsec_util.py -i io read 0x770 4

# set brightness (this example sets to the max value obtained from the above command)
sudo ./chipsec_util.py -i io write 0x774 4 0x00014187

We can also write a small python program that uses the Chipsec framework, here's an example. It can be useful if you want to read output without filtering extra Chipsec logs. To run it:

sudo PYTHONPATH=/path/to/chipsec ./chipsec_io_read.py

Credits