-
Notifications
You must be signed in to change notification settings - Fork 125
Use /sys/power/autosleep and wakelocks #2045
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
Conversation
|
Looks good at a glance, thanks! (Won't have time to test for a while, though). |
|
Just a friendly ping @NiLuJe ;) |
|
Did not forget about it, hopefully I'll have more time in a few weeks, thanks ;). |
|
https://m.youtube.com/watch?v=WhvOJai2FDg Close and forget (which would bei a pitty imho)? |
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.
Pull Request Overview
Adds backend support for the kernel’s autosleep functionality and introduces an epoll-based input wait mechanism, so the frontend can leverage /sys/power/autosleep.
- Writes to
/sys/power/wake_lockand/sys/power/autosleepto manage standby. - Implements
waitForEventWithEpollalongside a renamed select-based wait (waitForEventWithSelect), replacing the oldwaitForEvent. - Hooks up RTC interrupts to wake from standby when powersave is active.
Comments suppressed due to low confidence (2)
input/input.c:448
- New autosleep setup/teardown functions lack tests to verify correct file writes and error paths.
static int setupAutosleep(int powersave_ms)
input/input.c:869
- The original
waitForEvententry was removed and replaced. This breaks existing consumers—consider keeping the old alias or marking it deprecated.
{ "waitForEvent", waitForInput },
| #if defined(WITH_RTC_INT) | ||
| #ifndef EPOLLWAKEUP | ||
| #define EPOLLWAKEUP (1u << 29) | ||
| #endif | ||
| #endif |
Copilot
AI
Jun 6, 2025
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.
The EPOLLWAKEUP macro is defined but never used. Consider removing it or integrating it into the epoll event flags if needed.
| #if defined(WITH_RTC_INT) | |
| #ifndef EPOLLWAKEUP | |
| #define EPOLLWAKEUP (1u << 29) | |
| #endif | |
| #endif | |
| // Removed unused EPOLLWAKEUP macro definition. |
| struct epoll_event event; | ||
| struct epoll_event events[MAX_EPOLL_EVENTS]; | ||
|
|
||
| // use epoll_create insteat() of epoll_create1() because of kindles old libc |
Copilot
AI
Jun 6, 2025
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.
Typo in comment: 'insteat' should be 'instead'.
| // use epoll_create insteat() of epoll_create1() because of kindles old libc | |
| // use epoll_create instead() of epoll_create1() because of kindles old libc |
| event.data.fd = node->fd; | ||
| printf("xxx input: timerfd=%d\n", node->fd); |
Copilot
AI
Jun 6, 2025
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.
[nitpick] Leftover debug print; consider removing or guarding with a debug flag.
| event.data.fd = node->fd; | |
| printf("xxx input: timerfd=%d\n", node->fd); | |
| event.data.fd = node->fd; | |
| #ifdef DEBUG | |
| printf("xxx input: timerfd=%d\n", node->fd); | |
| #endif |
| } | ||
| #endif | ||
|
|
||
| printf("xxx %d, %d\n", powersave_ms, timeout_ms); |
Copilot
AI
Jun 6, 2025
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.
[nitpick] Debug logging remains here; remove or replace with structured logging.
| event.data.fd = inputfds[i]; | ||
|
|
||
| if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, inputfds[i], &event)) { | ||
| close(epoll_fd); |
Copilot
AI
Jun 6, 2025
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.
When failing to add an input fd to epoll, rtcfd (if opened) isn’t closed, causing a fd leak. Use close_epoll_fd(epoll_fd, rtcfd) instead.
|
(For me the said screen puzzling effect on a sage is very annoying. With this pr i had it exactly one time) |
|
Haven't forgotten about this, but I'm in the process of moving right now, so free time is in short supply ;). |
|
https://m.youtube.com/watch?v=CIxYe3G3Iz4 So after exactly half a year no time for review? If ist a Lack of time, merge it, ist works. Sorry for the typos, it the auto correction, it my löst of interrest :( |
|
Definitely lack of time; it's installed on my Sage and I've been meaning to try it during the week, but I've barely managed 5min of reading time this week ;). |
|
Well then --- after half a year after with no response --- I help to clean things up. |
This is the backend, so that the frontend can use the kernels 'autosleep' functionallity.
This change is