-
Notifications
You must be signed in to change notification settings - Fork 1
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
Keyboard backlight change UI #39
Comments
The ideapad platform driver it uses doesn't recognise the events the backlight sends (use |
yah, I can see |
@stuarthayhurst I dont have much knowledge (or really any at all) of linux kernel development, but I will be interested in working on one if you can fill me in on the required changes, if you think this is simple enough for someone with no background into linux kernel but background in C / C++ to be able to do then lmk and I can help out here :) |
The kernel is written in C, you'll find it in the I don't know how complex this will end up being, I've only spent a bit of time working on a driver for my headset, patches for my keyboard and testing other peoples' stuff. |
Yep, that's the event id that needs handling, but the backlight also needs to register with the kernel as an LED before the signal can be any use |
I did some more digging, and a keyboard backlight isn't even being registered with the kernel yet, so simply connecting the signal up wouldn't work.
If this doesn't work, then I'm out of my depth and it's a problem for someone at Lenovo. |
Hm no luck. No errors, it registers a keyboard, but it's stuck at brightness 0. |
Oh right, |
Hm, the driver seems set up to basically report either on / off, and set on / off. It doesn't seem to be aware of multiple brightness levels. Looking through the debug reported by the driver, none of the data parsed by the driver changes when the backlight changes, so the driver is completely unaware of the changes. This is going to take a much better knowledge of ACPI than I have, or specific knowledge of the laptop. Maybe someone at Lenovo knows, but considering it's not a Thinkpad, they probably won't care much about supporting it. Still worth a shot if anyone knows who to contact. |
thanks @stuarthayhurst for working on this, would it be possible to just implement it as an backlight on off indicator and maybe allow it to be turned on or off from the ui ? |
I wish I could help directly, I have been going over the ideapad driver source in case I can figure something out. These maybe are just for intel versions so not applicable here but thought I will share just in case. |
I'll test my machine later, but if he's found a way to configure the backlight using ACPI, that's exactly what I wasn't sure how to do. I'll look into this later and see if I can get something simple working. |
I get However, the values in his table have no effect on my system. Everything returns |
Could you attach the decompiled DSDT containing the KBLC function? I'm kind of curious now. |
Thanks for taking a look, it's Off / Low / High for the AMD version. |
Could you try the ACPI calls for set/query from my notes with the second lowest hexadecimal digit set to 2? E.g. 0x10023? I just skimmed the KBLC ACPI function. Based on your report of a call with 0x1 as an argument returning 0x5, this should at least do something. |
Yep, that works perfectly, thanks. I'll look into modifying the driver when I get time, but that won't be for a while. |
I presume the value read may indicate the number of supported states or the version of the protocol. The ACPI ASL code is the same as on my Intel model. You can deduce the second lowest hex digit from the 0x01 query. So a driver may work for both models. |
The core of it should be the same for the 2, where we need to set a new I'm not sure how the auto level would fit into the driver, but I also don't have the hardware to test it. |
Doing a test build now for a quick attempt at supporting the AMD version. I'll update with how it goes, but I won't be able to work on it for the next ~20 days as I'm busy. I'll upload my attempt at a patch in case anyone wants to work on it :) The Intel version will need different values, and handling for the auto state. A proper upstream-able version would also need proper error handling in the ACPI calls as well. Warning to anyone testing this: it's prodding at firmware, so who knows what happens if something goes wrong. |
Whoops, turns out I'm and idiot and forgot some braces. 0001-Attempt-patching-for-Yoga-keyboard.patch.txt EDIT: This patch works for setting the LED backlight, but it seems to be triggering the default case for the backlight reporting, so it reports 0. I probably just got the format of the returned values wrong, but I'm all out of time for now, but a driver is 100% possible for this keyboard. |
Never mind, I got it working :D That should apply cleanly to 6.4.4, or the latest @PJungkamp Since I don't have Intel hardware, it would be incredibly helpful if you could tweak the values and test your system too. I'm not sure about the cleanest way to support both at the same time, but feel free to work on that :) |
I haven't tried it yet. But the general idea would be:
All the values can actually be determined by some bitshifts. The return value
When I get around to it I'll slightly adapt your patch to these values, put some checks on those and post it here. |
Another small thing I remembered from my experiments. There is another way to get the current value of the backlight in the form of an integrated sensor sending events when the backlight state updates. For me it's this one. I found it while checking the Intel ISH sensors. There should be a similar hub for sensors on AMD platforms, but I don't know what Lenovo used there. |
Ah cool, thanks. What should be reported when the state is AUTO? I'd assume 0 as a default, because an error code implies a failure of some sort. I can't remember what the current patch will do in that case, I threw it together right before I had to leave. Speaking of throwing it together, I kind of just threw the new code paths in to test they worked. They could probably be integrated into the existing code much better, and any error reporting in there so far was for debug. On my AMD system, I had a quick look through some of the sensors present and couldn't see an obvious one to handle it, but I didn't look very thoroughly. |
The firmware handles AUTO as the 4th state, reporting 0x3. |
Sure, I meant what should the Giving it a number isn't necessarily correct, as we don't know the actual brightness, only that it's in auto mode. Giving it 0 seems most appropriate, as an error code implies an issue, when everything is behaving. |
0001-platform-x86-ideapad-laptop-Add-support-for-keyboard.patch.txt
I haven't tested this patch yet, but it applies to the current EDIT: Tested it, works just fine for my system. Hopefully it works well on Intel too :) EDIT 2: This patch v2 has better comments, extra whitespace removed and a shared path in the set call (previously it was a bit rigged together for testing) v2-0001-platform-x86-ideapad-laptop-Add-support-for-keyboard.patch.txt EDIT 3: Tested, working fine |
Some small notes upon reading it:
|
Whoops, forgot to fix that part, thanks I also don't really like returning 0 for auto, but I'm probably going to have to ask a mailing list to see what would be accepted upstream. Possibilities:
None of these feel like a good fit, so I just chucked 0 in there for now, until we have a better answer :) |
v5-0001-platform-x86-ideapad-laptop-Add-support-for-keyboard.patch.txt This one uses bit shifting for reading the brightness of the keyboard, and validates the returned value. It could do with testing for both Intel and AMD users, but it's all working on my system. If everyone else is happy with it, I'll send it upstream, and ask about how to handle the auto value, in a way that would be accepted upstream. |
@stuarthayhurst is this sent to upstream ? |
No, so far I don't know if anyone's tested it other than me, ideally I'd be sure it works on Intel before I send it. |
I think @PJungkamp has an Intel system, so they can confirm this. |
@sidevesh I noticed you have the 14ACN6, which is different from my 14ARB7. If possible, could you also test please? |
I can try, I have never compiled linux from scratch though, I am using arch with linux-zen kernel, will it be possible to apply this on top of linux-zen ? |
I don't see why not, This seems like a good place to start: https://wiki.archlinux.org/title/Kernel/Arch_build_system |
@stuarthayhurst I tested it out and it worked, only issue I saw was that there was no indicator when it shifted to AUTO |
As long as there are no errors in |
Forgot to update this thread, it's been sent upstream: https://lore.kernel.org/platform-driver-x86/20230825122925.7941-1-stuart.a.hayhurst@gmail.com/T/#u Up to the 3rd revision on that mailing list now, but hopefully it'll land in time for 6.6, as Feel free to test the patch again if you have a keyboard with the AUTO state, it should still work, but it doesn't hurt to be safe. |
Pulled into Upstream didn't comment on the auto handling, so if anyone wants to fix that, you'll probably need to add a sysfs attribute or something to communicate that. |
looks to me like auto brightness setting is just not a thing anywhere in the stack, from the kernel to upower dbus to DE (GNOME atleast, including with the newly added quick toggle in 45) Question, do we get a report from the acpi when the backlight changes automatically ? https://upower.freedesktop.org/docs/KbdBacklight.html supports BrightnessChangedWithSource which can be used to indicate if brightness was changed internally, maybe when auto gets set we just pull the current brightness and notify that, |
Pulled into mainline: torvalds/linux@ecaa186 Since the 14ARB7 doesn't have auto handling, can this be closed? |
Sure, if you have any pointers on the AUTO handling then will appreciate it so I can try getting it set up for my system which does support AUTO. |
Personally, I'd ask on a mailing list about how it should be handled, as I don't know myself. If you figure it out, you'll have to remove the condition or two in there to treat it as
No problem :) |
I recently installed the Linix 6.6 release and the keyboard backlight pop up does not seem to be showing for me, I had tested the patch earlier when it was in development and it was working, did this not get releaeed in 6.6 and is it working for you @stuarthayhurst ? |
It made it to 6.6, it was working last time I tested a 6.6 kernel, but 6.6 hasn't made it to Debian Sid / Experimental yet, so I'm still running 6.5 day-to-day The patch was changed during review for the kernel, the final commit can be found here: torvalds/linux@ecaa186 |
I'm using 6.6 and Plasma, the power applet works wonderfully, I can adjust
backlight from there, and it reports real time any change done by keyboard
shortcut.
Cool job.
Atentament:
Jordi Paradell
***@***.***
Missatge de Stuart Hayhurst ***@***.***> del dia dv., 10 de
nov. 2023 a les 1:41:
… It made it to 6.6, it was working last time I tested a 6.6 kernel, but 6.6
hasn't made it to Debian Sid / Experimental yet, so I'm still running 6.5
day-to-day
The patch was changed during review for the kernel, the final commit can
be found here: ***@***.***
<torvalds/linux@ecaa186>
—
Reply to this email directly, view it on GitHub
<#39 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADJ52UMLH2L3WY7GKLRUBJLYDVZ5JAVCNFSM6AAAAAAYVUVSO2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBUHA4TMOJZHE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@sidevesh If it's still not working, can you double check that you're running 6.6 ( |
@stuarthayhurst sudo lsmod |grep ideapad:
|
Do you have anything in |
|
Do you have any messages about EDIT: |
|
Ah, I think you had it in auto mode when the device started, causing the get function to fail, so the initial value was an error, so the init failed and the keyboard wasn't registered. I guess my code to handle AUTO is broken :/ I'll try patch this and send you something for testing, thanks for catching this EDIT: Never mind, it seems we use |
Here's a @sidevesh Can you give that a test please? If it doesn't work for you I'll write another :) EDIT: Tested on my system, no regressions. Sent upstream anyway, as it needed to be fixed, whether or not it actually caused your issue. As I mentioned earlier, if it doesn't work for you I'll keep troubleshooting :) EDIT 2: Accepted into platform-drivers-x86 |
@stuarthayhurst sorry for the delay, I will test out the patch this weekend and let you know if the issue gets fixed or if I encounter any issues, thanks for resolving this so quickly! |
Same problem here. I totally forgot about this thread as I'm kind of busy recently. I'll try your patch right away and report back. |
It's working beautifully! GNOME 45 just hit The ACPI does not seem to provide an event when the keyboard backlight is changed using the keyboard shortcut (fn+space). Maybe I'll give this another go myself if I've got some time (this and some sensible reporting of an |
I have an AMD 5800O Yoga 7 14ACN6, which is similar to this.
One minor issue in interest of listing everything is that while the keyboard backlight changing works via the Fn+Space shortcut,
it does not reflect in UI and no pop up / osd is shown in gnome.
In my older laptops the keyboard backlight changes would show an osd,
This is something listed in the last point at https://github.com/PJungkamp/yoga9-linux#extra-features:
DOes this work normally in 14ARB7 for y'all ?
The text was updated successfully, but these errors were encountered: