Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Mar 9, 2025

This is the backend, so that the frontend can use the kernels 'autosleep' functionallity.


This change is Reviewable

@NiLuJe
Copy link
Member

NiLuJe commented Mar 9, 2025

Looks good at a glance, thanks!

(Won't have time to test for a while, though).

@ghost ghost marked this pull request as ready for review March 13, 2025 15:29
@ghost
Copy link
Author

ghost commented May 4, 2025

Just a friendly ping @NiLuJe ;)

@NiLuJe
Copy link
Member

NiLuJe commented May 5, 2025

Did not forget about it, hopefully I'll have more time in a few weeks, thanks ;).

@ghost ghost requested a review from Copilot June 6, 2025 21:39
@ghost
Copy link
Author

ghost commented Jun 6, 2025

https://m.youtube.com/watch?v=WhvOJai2FDg

Close and forget (which would bei a pitty imho)?

Copy link

Copilot AI left a 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_lock and /sys/power/autosleep to manage standby.
  • Implements waitForEventWithEpoll alongside a renamed select-based wait (waitForEventWithSelect), replacing the old waitForEvent.
  • 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 waitForEvent entry was removed and replaced. This breaks existing consumers—consider keeping the old alias or marking it deprecated.
{ "waitForEvent", waitForInput },

Comment on lines +42 to +46
#if defined(WITH_RTC_INT)
#ifndef EPOLLWAKEUP
#define EPOLLWAKEUP (1u << 29)
#endif
#endif
Copy link

Copilot AI Jun 6, 2025

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.

Suggested change
#if defined(WITH_RTC_INT)
#ifndef EPOLLWAKEUP
#define EPOLLWAKEUP (1u << 29)
#endif
#endif
// Removed unused EPOLLWAKEUP macro definition.

Copilot uses AI. Check for mistakes.
struct epoll_event event;
struct epoll_event events[MAX_EPOLL_EVENTS];

// use epoll_create insteat() of epoll_create1() because of kindles old libc
Copy link

Copilot AI Jun 6, 2025

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'.

Suggested change
// use epoll_create insteat() of epoll_create1() because of kindles old libc
// use epoll_create instead() of epoll_create1() because of kindles old libc

Copilot uses AI. Check for mistakes.
Comment on lines +576 to +577
event.data.fd = node->fd;
printf("xxx input: timerfd=%d\n", node->fd);
Copy link

Copilot AI Jun 6, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
}
#endif

printf("xxx %d, %d\n", powersave_ms, timeout_ms);
Copy link

Copilot AI Jun 6, 2025

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.

Copilot uses AI. Check for mistakes.
event.data.fd = inputfds[i];

if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, inputfds[i], &event)) {
close(epoll_fd);
Copy link

Copilot AI Jun 6, 2025

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.

Copilot uses AI. Check for mistakes.
@ghost
Copy link
Author

ghost commented Jun 6, 2025

(For me the said screen puzzling effect on a sage is very annoying. With this pr i had it exactly one time)

@NiLuJe
Copy link
Member

NiLuJe commented Jun 7, 2025

Haven't forgotten about this, but I'm in the process of moving right now, so free time is in short supply ;).

@ghost
Copy link
Author

ghost commented Aug 9, 2025

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.
If ist a Lack of interrest drop it (than my Koreaner Version ist freezed at this Point, aus I have the Screen puzzling effect).

Sorry for the typos, it the auto correction, it my löst of interrest :(

@NiLuJe
Copy link
Member

NiLuJe commented Aug 9, 2025

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 ;).

@ghost
Copy link
Author

ghost commented Sep 22, 2025

Well then --- after half a year after with no response --- I help to clean things up.

@ghost ghost closed this Sep 22, 2025
@ghost ghost deleted the epoll branch September 22, 2025 17:16
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant