Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new submodule as an alternative to Backlight Registers Fix (BLR), fixing the 3-minute dark screen issue and making Backlight Smoother (BLS) work on mobile Coffee Lake platforms running macOS 13.4 or later #113
Add a new submodule as an alternative to Backlight Registers Fix (BLR), fixing the 3-minute dark screen issue and making Backlight Smoother (BLS) work on mobile Coffee Lake platforms running macOS 13.4 or later #113
Changes from 3 commits
9e3e2eb
ac8bfe5
45eccad
c18444e
8147b64
ba3ca8e
f191739
039806f
9304cd6
35ac5b1
6575154
496d07a
a4dded9
4caf663
ea6d7e8
6c1294a
8017057
f5ce20e
dfe7b7c
198e479
5c2cae8
d0037fd
8432fbc
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppleIntelFramebufferController::hwSetBacklight is rather short, maybe it is more reasonable to solve the field offsets and simply rewrite the function ourselves?
a2
argument), so two other ifs and MMIO ops also do not matter for us.What we are left with is:
mov [rbx+2E78h], r14d
backlight level set in the end of the function.mov rcx, [rbx+1A08h]
MMIO space.Perhaps do it the other way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also be smarter and perform offset detection in dynamic.
For this you could:
Now you have both offsets you need, so you can just reimplement AppleIntelFramebufferController::hwSetBacklight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I carefully revisited
hwSetBacklight
and its callersLightUpEDP
andhwSetPanelPower
, and I think that finding the offset of each required member field and rewritinghwSetBacklight
is the right approach to this issue.Yes, we do have own logic for updating registers at
0xc8254
and0xc8258
, but I am not sure which two MMIO ops you referred to do not matter. Here is Apple's implementation and my thoughts are...0x2e60
.0x1d30
.WriteRegister32()
explicitly.0x1a08
.0x2e84
.0xFFFF
and stores in the member field at0x2e80
, but there is no guarantee that the value remains the same forever.0x2e80
.hwSetPanelPower
andLightUpEDP
always invokehwSetBacklight
with the brightness value stored in the member field at0x2e78
, so it's weird thathwSetBacklight
just stores the same value to that member field again, but I think it's better to keep this in our implementation.0x2e78
.Your proposed approach that uses dummy controller objects is really interesting, but I think it's better to disassemble
hwSetBacklight()
, identify the offsets of the divider and the brightness level and implement the backlight registers fix in ourhwSetBacklight()
wrapper. Now the problem lies in the caller site. I managed to disassemble those two callers and generate the assembly patch for each of them at runtime so that they will callhwSetBacklight()
explicitly. I have added a new patch submodule to reflect the new changes and can confirm that it works on my machine properly. It would be great if you can review it and provide suggestions on making the new submodule easier to maintain in future. Once you approve the new changes, I will remove the supplemental fix from the WEG.