Skip to content

Add deep sleep (Suspend-to-RAM) support for capable devices #62

@nchapman

Description

@nchapman

Summary

For devices that support kernel Suspend-to-RAM (S2RAM), enter deep sleep instead of shutting down after the fauxSleep timeout. This preserves full system state for instant resume instead of losing it.

Background

Currently, LessUI uses "fauxSleep" which:

  • Turns off the backlight immediately
  • Pauses audio
  • Pauses keymon
  • Polls for wake button every 200ms
  • Auto-powers off after 2 minutes if not charging (losing all state)

FauxSleep provides good UX - instant screen off, quick wake if you change your mind. The problem is only what happens after the timeout: shutdown loses all state.

Some devices (confirmed: RG35XX Plus) support true Suspend-to-RAM via /sys/power/state. The System Report pak now detects this capability.

Proposed Change

Keep fauxSleep exactly as-is for the immediate sleep experience. Change only what happens at the timeout:

Scenario Current Behavior Proposed Behavior
Wake within timeout Exit fauxSleep, continue Exit fauxSleep, continue
No wake after timeout Shutdown (state lost) Deep sleep (state preserved)
Wake from deep sleep N/A Kernel resumes → exit fauxSleep → continue

The timeout before entering deep sleep could potentially be shorter than the current 2-minute shutdown timeout, since state is preserved.

Benefits

  • FauxSleep UX unchanged (instant screen off, quick wake)
  • After timeout: state preserved instead of lost
  • Much better battery life than fauxSleep polling
  • Resume exactly where you left off (game in progress, menu position, etc.)

Implementation Approach

  1. Platform flag: Add #define PLATFORM_DEEP_SLEEP 1 to platform.h for supported devices
  2. Modify PWR_waitForWake(): At timeout, write "mem" to /sys/power/state instead of calling PWR_powerOff()
  3. Wake handling: Kernel resumes execution in PWR_waitForWake(), which returns normally
  4. Fallback: If platform doesn't support deep sleep, keep current shutdown behavior

Devices to Evaluate

Based on System Report data, evaluate deep sleep support on:

  • rg35xxplus (confirmed: supports mem state)
  • rg35xx
  • tg5040
  • rgb30
  • my355
  • miyoomini (likely no kernel support)
  • trimuismart

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions