Disable Color Dither method collection
- Edited
it would be great if we could get in touch with these two guys
- Authors: Dave Airlie
- Alex Deucher
*/
#include <drm/drmP.h>
#include <drm/drm_edid.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_fb_helper.h>
#include <drm/amdgpu_drm.h>
#include "amdgpu.h"
#include "atom.h"
#include "atombios_encoders.h"
#include "atombios_dp.h"
#include "amdgpu_connectors.h"
#include "amdgpu_i2c.h"
#include <linux/pm_runtime.h>
if (property == adev->mode_info.dither_property) {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
return 0;
amdgpu_encoder = to_amdgpu_encoder(encoder);
if (amdgpu_connector->dither != val) {
amdgpu_connector->dither = val;
amdgpu_connector_property_change_mode(&amdgpu_encoder->base);
}
}
I believe it is possible to disable Dithering on Mac Os for Intel Video card (I'm using MacBook pro 2018 with Intel UHD Graphic 630).
I was researching driver's code via decompiler and found some interesting configuration parameters.
At first, I recommend looking at what kexts are loaded. This can be done using kextstat | grep Intel
command.
Here is my output:
https://ibb.co/tCDQKMY
I believe that the underlying issue lays one of the *Framebuffer.kext files, decompiled code for mine com.apple.driver.AppleIntelCFLGraphicsFramebuffer
looks like:
https://ibb.co/8YGC1Wh
AppleIntelFramebufferController::getFeatureControl
method seems to load data from underlying Info.Plist
All you need to do in order to disable dithering is simply add a new parameter to the section
IOKitPersonalities->AppleIntelFramebufferController->FeatureControl
in file /System/Library/Extensions/AppleIntelCFLGraphicsFramebuffer.kext/Contents/Info.plist
Right-click on FeatureControl
section in the xcode, and new Number
parameter.
name: DitherDisable
value: 1
Here are the contents of my Info.Plist file (with new parameter included):
https://ibb.co/dgqK0MS
Side note: in order to actually make changes to plist inside kext, you need to disable security protection
https://apple.stackexchange.com/a/251559/320465
In short, reboot mac, holding Command+R until recovery utility is loaded.
Open terminal there (from top menu), and type:
csrutil disable
Restart your mac normally. Now you need to add more permissions to be able to edit that file:
cd /System/Library/Extensions/AppleIntelCFLGraphicsFramebuffer.kext/
sudo chown $USER Contents/
cd Contents
sudo chown $USER Info.plist
Edit plist file as shown above in xcode.
Then I'd like to return file ownership back to root user:
sudo chown root Info.plist
cd ..
sudo chown root Contents/
Let me know if your eyes are better now. For me it seems to help a lot, but need few days.
Here is proof that colors are different after fix (banding appeared on intel):
https://ibb.co/pR807tD
https://ibb.co/PY4PZ71
Note: this will only work for Intel as for now. To check active video card - use activity monitor->Energy tab
I was trying to apply similar fix for integrated AMD video card, but stuck on apple logo screen.
And now I stuck with AMD card dithering. Whenever graphic switches to High-perf (opening Photoshop, Sketch, or simply changing power saving option to Automatic graphics switching
), I notice immediate nausea. It is not as bad as with intel, but still not comfortable.
It is really hard to explain, it is a sensation that letters are jumping, even when screen image is static. Like visual noise.
I wonder if someone can shed a light of what this could be, inside AMDFramebuffer.kext
https://ibb.co/pPwDFhf
I'm particularly interested in CFG_DEF_DITH
. I tried to add this parameter in Info.plist, without success.
It seems for me that AMD driver configuration is split and duplicated among several kext, and that is hard to glue together.
- Edited
Gleb I have an Intel HD4000 Mac Mini lying around which I can't use due to strain - I will definately give this a try today.
Can I use this code with older versions of MacOS?
Also I am interested to know your story; when did you notice symptoms yourself on Macs or other machines, and how did you find out this kext information?
- Edited
Gleb Id like to try this, but am a bit afraid of ruining my macos and having to reinstall. Im getting treated for heterophoria (which you might also have, ever visited a good optometrist?), Its proven to be connected from my own experience with the treatment, but sometimes not 100% treatable so Id still welcome a technical solution.
- Would there be a chance to write this into a simple app that can be used on the taskbar to switch dithering on/off? Id pay you money for it.
- Wasnt there an app (gfx card) that could force using integrated intel graphics even when photoshop etc. is running?
You can also write me at mjanas555 {that at sign} googlemail {dot} com
diop Please let me know if it indeed helps with symptoms.
Can I use this code with older versions of MacOS?
I think yes. But the final answer depends on the Kext in use. You can list Intel kext's to see if we are using same version. If there are different framebuffers, you can send me framebuffer kext and I can take a look if it has this hidden parameter.
when did you notice symptoms
I got eye strain after 3-4 months of using MacBook pro. It became worse when I changed lights in my apartment to PWM led strips. Now I do not use LED lightings, just old lightbulb, and desk lamp. Also, I switched my primary screen from MacBook screen to external Displays (Dell UP2414q). Not starring all day into MacBook screen seems to give me relief.
Never had any problems with most screens for 20 years. Only some crappy glossy PWM displays made me uncomfortable, but I avoided them with success.
how did you find out this kext information?
You need some sort of decompiler. I Use IDA64 with hex-rays plugin.
Then I went into each suspicious Kext (Show content) and pulled binary into IDA64. You are interested to decompile Unix Executable in *.kext/Contents/MacOS/
:
https://ibb.co/JCRx1TY
Then in IDA - View->Open Subview->Strings (Shift+F12)
And try to search for Dither
there. x
key on the string will show all code usages for this string. Go there and press F5 for hex-rays C-like decompiled code
martin Yesterday I screw up with AMD driver modification (every time I set CFG_NO_DITH
- I can't restart machine anymore, stuck on logo, about 70%)
The way to fix is to load in recovery mode (holding command+R) and copy unmodified kexts from recovery partiyion to your /System/Library/Extensions/
Here I did screenshot of commands I use for restoring original kext:
https://ibb.co/Gt0X1YH
Gleb I cant even get the first command in terminal running - kextstat | grep Intel
Martin-MacBook-Pro:~ martinjanas$ kexstat | grep Intel
-bash: kexstat: command not found
You are probably very experienced and so certain things seem as given, is there more dumbed down version of how to do this?
Also how about installing windows 10 via bootcamp and trying to disable all of it there to see if it indeed helps your eyes? Could you do that and share the process? Its good testing ground as its easy to wipe it if it goes wrong and still keep macos intact. If it works there, then its good motivation to figure it out for macos.
- Edited
kextstat | grep Intel
That was a typo somewhere
Windows
I do not have much free space currently for it. But even in MacOS flipping integrated\discrete card switch makes a HUGE difference in how fonts and colors looks. Also now it is relaxing on eyes (my gf also see a difference with and without dithering)
- Edited
Gleb Okay so I've got the Mac powered on - disabled csrutil first then restarted.
My drivers loaded look quite different - https://imgur.com/uKdcGfz
- Edited
diop Unfortunately I do not see this hidden parameter for FramebufferCapri:
You may try to set Dither
instead of mine DitherDisable
number
= 0
to disable it, if I understood Framebuffer code correctly
But I can't promise results. Still worth trying.
In the meantime, I wonder if you install SwitchResX
https://www.madrau.com/srx_download/download.html
And reduce colors to Millions of color, instead of billions https://ibb.co/44P4CDQ
AND, more important, in System Preferences -> Display -> Color, select Generic RGB Profile
instead of Color LCD
https://ibb.co/hXz3JmG
Then it seems to disable (or at least reduce) dithering effects.
You can verify it on gradient image http://www.lagom.nl/lcd-test/gradient.php
It should look banded, not linear gradient as here: https://ibb.co/PY4PZ71
Can you try it and share the experience?