From 66bb1e3d3625cb963e31fc23906b8ec0a9a7cab7 Mon Sep 17 00:00:00 2001 From: fewtarius Date: Thu, 8 Feb 2024 23:14:25 +0000 Subject: [PATCH] Disable 2S fan in sleep mode, and put the device into power saving mode since sleep is really freeze. After 8 minutes the core temp remained at 35c tested immediately after wake. Longer testing needed. --- .../AYANEO AYANEO 2S/sleep.d/post/001-fan | 7 ++++++ .../AYANEO AYANEO 2S/sleep.d/post/002-freq | 22 +++++++++++++++++++ .../AYANEO AYANEO 2S/sleep.d/pre/001-fan | 8 +++++++ .../AYANEO AYANEO 2S/sleep.d/pre/002-freq | 17 ++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/001-fan create mode 100644 packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/002-freq create mode 100644 packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/001-fan create mode 100644 packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/002-freq diff --git a/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/001-fan b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/001-fan new file mode 100644 index 000000000..84c1f6285 --- /dev/null +++ b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/001-fan @@ -0,0 +1,7 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +. /etc/profile + +systemctl restart fancontrol diff --git a/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/002-freq b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/002-freq new file mode 100644 index 000000000..b8527a417 --- /dev/null +++ b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/post/002-freq @@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +### Restore previous governors before going to sleep + +. /etc/profile + +### Grab the old governors. +OLD_CPU_FREQ=$(get_setting "sleep.cpugovernor") +if [ ! -n "${OLD_CPU_FREQ}" ]; then + OLD_CPU_FREQ="schedutil" +fi + +OLD_GPU_LEVEL=$(get_setting "sleep.gpulevel") +if [ ! -n "${OLD_GPU_LEVEL}" ]; then + OLD_GPU_LEVEL="balanced" +fi + +# Restore old governors. +set_cpu_gov "${OLD_CPU_FREQ}" +gpu_performance_level "${OLD_GPU_LEVEL}" diff --git a/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/001-fan b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/001-fan new file mode 100644 index 000000000..df3ee2647 --- /dev/null +++ b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/001-fan @@ -0,0 +1,8 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +. /etc/profile + +echo 1 >${DEVICE_PWM_FAN} +echo 0 >${DEVICE_FAN_INPUT} diff --git a/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/002-freq b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/002-freq new file mode 100644 index 000000000..44f3f67bd --- /dev/null +++ b/packages/hardware/quirks/devices/AYANEO AYANEO 2S/sleep.d/pre/002-freq @@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +# Store current freq governors and set governors to powersave. + +. /etc/profile + +### Get the current cpu and gpu governor, save for when the device wakes from sleep. +CUR_CPU_FREQ="$(cat ${CPU_FREQ}/scaling_governor)" +CUR_GPU_LEVEL="$(get_gpu_performance_level)" +set_setting sleep.cpugovernor "${CUR_CPU_FREQ}" +set_setting sleep.gpulevel "${CUR_GPU_LEVEL}" + +### Set all governors to powersave +set_cpu_gov powersave +gpu_performance_level low