* Improved support for AMD p-state drivers (<7w idle on AMD 6800U).

* Break Loki Zero link to configure proper default TDP for Max and MiniPro.
* Revert drain when charged while powered off support for RK3566.
This commit is contained in:
fewtarius 2023-11-26 19:03:00 +00:00
parent b0991f8064
commit 947c482a37
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
18 changed files with 386 additions and 73 deletions

View file

@ -1 +0,0 @@
ayn Loki Zero

View file

@ -0,0 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/010-led_control
DEVICE_LED_CONTROL="true"
DEVICE_LED_BRIGHTNESS="true"
EOF

View file

@ -0,0 +1,11 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile.d/001-functions
AUDIO_LATENCY=$(get_setting audiolatency)
if [ -z "${AUDIO_LATENCY}" ]
then
set_setting global.audiolatency 64
fi

View file

@ -0,0 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/020-fan_control
DEVICE_HAS_FAN="true"
DEVICE_PWM_FAN="$(find /sys/devices/platform/ayn-platform -name pwm1)"
DEVICE_FAN_INPUT="$(find /sys/devices/platform/ayn-platform -name fan*_input)"
DEVICE_TEMP_SENSOR="$(find /sys/devices/pci*/* -path "*/nvme" -prune -o -name temp1_input -print)"
EOF

View file

@ -0,0 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/050-modifiers
DEVICE_FUNC_KEYA_MODIFIER="BTN_MODE"
DEVICE_FUNC_KEYB_MODIFIER="KEY_LEFTSHIFT"
EOF

View file

@ -0,0 +1,78 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
DEBUG=false
COOLING_PROFILE=$(get_setting "cooling.profile")
log $0 "Setting profile to ${COOLING_PROFILE}"
function set_control() {
log $0 "Set fan control to ${1}"
ectool -w 0x10 -z ${1} >/dev/null 2>&1
}
trap "set_control 0x01 && exit 0" SIGHUP SIGINT SIGQUIT SIGABRT
if [ -e "/storage/.config/fancontrol.conf" ] && [ "${COOLING_PROFILE}" = "custom" ]
then
log $0 "Loading configuration file" 2>/dev/null
source /storage/.config/fancontrol.conf
if [ ! $? = 0 ]
then
WARN="Custom fan profile could not be loaded, defaulting to auto."
log $0 "${WARN}"
COOLING_PROFILE="auto"
set_setting cooling.profile auto
fi
fi
if [ ! "${COOLING_PROFILE}" = "custom" ]
then
if [ "${COOLING_PROFILE}" = "aggressive" ]
then
SPEEDS=(128 96 72)
TEMPS=(70000 65000 0)
elif [ "${COOLING_PROFILE}" = "moderate" ]
then
SPEEDS=(128 96 72 64 48)
TEMPS=(70000 65000 60000 55000 0)
elif [ "${COOLING_PROFILE}" = "quiet" ]
then
SPEEDS=(128 96 64 48 32)
TEMPS=(70000 65000 60000 55000 0)
else
# auto
set_control 0x01 >/dev/null 2>&1
exit 0
fi
fi
log $0 "Enabling fan control."
set_control 0x00 >/dev/null 2>&1
while true
do
INDEX=0
CPU_TEMP=$(printf "%.0f" $(awk '{ total += $1; count++ } END { print total/count }' ${DEVICE_TEMP_SENSOR}))
$DEBUG && log $0 "CPU TEMP: ${CPU_TEMP}" 2>/dev/null
for TEMP in "${TEMPS[@]}"
do
if (( "${CPU_TEMP}" > "${TEMP}" )) && \
[ ! "${LASTSPEED}" = "${SPEEDS[${INDEX}]}" ]
then
$DEBUG && log $0 "Setting PWM FAN to ${SPEEDS[${INDEX}]} (${TEMP})" 2>/dev/null
ectool -w 0x11 -z $(printf '%x\n' ${SPEEDS[${INDEX}]}) >/dev/null 2>&1
LASTSPEED=${SPEEDS[${INDEX}]}
break
fi
INDEX=$(( $INDEX + 1 ))
done
sleep 2
done
log $0 "Disabling fan control."
set_control 0x01 >/dev/null 2>&1

View file

@ -0,0 +1,173 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
#
# A simple tool to manipulate the controller LEDs using ectool, thanks to
# Ayn for the sample code.
#
# Schema:
#
# 0xB3 - RGB Mode
# 0xAA - Save
#
# 0xB0 - Red
# 0xB1 - Green
# 0xB2 - Blue
#
. /etc/profile
RGB_RED="0xB0"
RGB_GREEN="0xB1"
RGB_BLUE="0xB2"
RGB_MODE="0xB3"
RGB_SAVE="0xAA"
RGB_IDLE="0x55"
ECTOOL="/usr/sbin/ectool"
DEBUG=false
function debug_out() {
$DEBUG && echo "ledcontrol: $*"
}
function ec_save() {
TIMEOUT=0
while true
do
STATE="0x$(${ECTOOL} -r ${RGB_MODE})"
if [ "${STATE^^}" == "${RGB_SAVE}" ] || \
[ "${STATE}" == "${RGB_IDLE}" ] || \
[ "${TIMEOUT}" == 5 ]
then
break
fi
sleep .5
TIMEOUT=$(( TIMEOUT + 1 ))
done
${ECTOOL} -w ${RGB_MODE} -z ${RGB_SAVE} >/dev/null 2>&1
}
function ec_set() {
debug_out "Set EC ${1} ${2}"
${ECTOOL} -w ${1} -z ${2} >/dev/null 2>&1
}
function off() {
ec_save
ec_set ${RGB_RED} 0x00
ec_set ${RGB_GREEN} 0x00
ec_set ${RGB_BLUE} 0x00
ec_save
}
function intensity() {
printf "0x%X\n" $((${1} / ${2}))
}
GETBRIGHTNESS=$(get_setting led.brightness)
if [ ! -z "${2}" ]
then
LEDBRIGHTNESS=${2}
debug_out "Arg[2]: ${2}"
elif [ ! -z "${GETBRIGHTNESS}" ]
then
LEDBRIGHTNESS=${GETBRIGHTNESS}
debug_out "GETBRIGHTESS: ${GETBRIGHTNESS}"
else
debug_out "NO SETTING: max"
LEDBRIGHTNESS=mid
set_setting led.brightness max
fi
case ${LEDBRIGHTNESS} in
max)
LEDBRIGHTNESS=1
set_setting led.brightness max
;;
mid)
LEDBRIGHTNESS=2
set_setting led.brightness mid
;;
min)
LEDBRIGHTNESS=4
set_setting led.brightness min
;;
esac
case $1 in
red)
off
COLOR=$(intensity 0xFF ${LEDBRIGHTNESS})
ec_set ${RGB_RED} ${COLOR}
ec_set ${RGB_GREEN} 0x00
ec_set ${RGB_BLUE} 0x00
ec_save
set_setting led.color red
;;
green)
off
COLOR=$(intensity 0xFF ${LEDBRIGHTNESS})
ec_set ${RGB_RED} 0x00
ec_set ${RGB_GREEN} ${COLOR}
ec_set ${RGB_BLUE} 0x00
ec_save
set_setting led.color green
;;
blue)
off
COLOR=$(intensity 0xFF ${LEDBRIGHTNESS})
ec_set ${RGB_RED} 0x00
ec_set ${RGB_GREEN} 0x00
ec_set ${RGB_BLUE} ${COLOR}
ec_save
set_setting led.color blue
;;
teal)
off
COLOR=$(intensity 0x80 ${LEDBRIGHTNESS})
ec_set ${RGB_RED} 0x00
ec_set ${RGB_GREEN} ${COLOR}
ec_set ${RGB_BLUE} ${COLOR}
ec_save
set_setting led.color teal
;;
purple)
off
COLOR=$(intensity 0x80 ${LEDBRIGHTNESS})
ec_set ${RGB_RED} ${COLOR}
ec_set ${RGB_GREEN} 0x00
ec_set ${RGB_BLUE} ${COLOR}
ec_save
set_setting led.color purple
;;
white)
off
COLOR=$(intensity 0x80 ${LEDBRIGHTNESS})
ec_set ${RGB_RED} ${COLOR}
ec_set ${RGB_GREEN} ${COLOR}
ec_set ${RGB_BLUE} ${COLOR}
ec_save
set_setting led.color purple
;;
off)
off
set_setting led.color off
;;
default)
del_setting led.color
ec_set ${RGB_MODE} 0x00
;;
brightness)
set_setting led.brightness ${2}
ledcontrol $(get_setting led.color)
;;
*)
COLOR=$(get_setting led.color)
if [ ! -z "${COLOR}" ]
then
ledcontrol ${COLOR}
fi
;;
esac

View file

@ -1 +1 @@
ayn Loki Zero
ayn Loki Max

View file

@ -0,0 +1,15 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile.d/001-functions
### Set the default device configuration
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="6w"
DEVICE_LED_CONTROL="false"
DEVICE_LED_BRIGHTNESS="false"
DEVICE_HAS_FAN="false"
DEVICE_VOLUMECTL="true"
DEVICE_BRIGHTNESS="hardware"
EOF

View file

@ -123,7 +123,7 @@ fi
### We need the original system cooling profile later so get it now!
COOLINGPROFILE=$(get_setting cooling.profile)
### Set CPU TDP (AMD) or EPP (Intel)
### Set CPU TDP and EPP
CPU_VENDOR=$(cpu_vendor)
case ${CPU_VENDOR} in
AuthenticAMD)
@ -134,15 +134,14 @@ case ${CPU_VENDOR} in
/usr/bin/overclock ${OVERCLOCK}
fi
;;
GenuineIntel)
EPP=$(get_setting "power.epp" "${PLATFORM}" "${ROMNAME##*/}")
if [ ! -z ${EPP} ]
then
/usr/bin/set_epp ${EPP}
fi
;;
esac
EPP=$(get_setting "power.epp" "${PLATFORM}" "${ROMNAME##*/}")
if [ ! -z ${EPP} ]
then
/usr/bin/set_epp ${EPP}
fi
GPUPERF=$(get_setting "gpuperf" "${PLATFORM}" "${ROMNAME##*/}")
if [ ! -z ${GPUPERF} ]
then

View file

@ -70,30 +70,51 @@ pcie_aspm_policy() {
cpu_perftune() {
CPUPOWERSAVE=$(get_setting system.power.cpu)
POWERSAVEENABLED=$(get_setting system.powersave)
CPU="$(awk '/vendor_id/ {print $3;exit}' /proc/cpuinfo)"
if [ "${CPUPOWERSAVE}" = "1" ] && \
[ "${POWERSAVEENABLED}" = "1" ]
then
CPU="$(awk '/vendor_id/ {print $3;exit}' /proc/cpuinfo)"
if [ "${CPU}" = "AuthenticAMD" ]
then
if [ "${1}" = "battery" ]
then
ryzenadj --power-saving >/dev/null 2>&1
else
ryzenadj --max-performance >/dev/null 2>&1
fi
elif [ "${CPU}" = "GenuineIntel" ]
then
for policy in $(find /sys/devices/system/cpu/cpufreq/policy*/ -name energy_performance_preference)
do
case ${CPU} in
AuthenticAMD)
if [ "${1}" = "battery" ]
then
echo power >${policy} >/dev/null 2>&1
ryzenadj --power-saving >/dev/null 2>&1
else
echo performance >${policy} >/dev/null 2>&1
ryzenadj --max-performance >/dev/null 2>&1
fi
done
fi
;;
esac
fi
case ${CPU} in
AuthenticAMD)
PSTATE="amd_pstate"
STATUS="active"
;;
GenuineIntel)
PSTATE="intel_pstate"
STATUS="passive"
;;
esac
if [ -f "/sys/devices/system/cpu/${PSTATE}/status" ]
then
echo ${STATUS} >/sys/devices/system/cpu/${PSTATE}/status
while [ ! -f /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference ]
do
sleep .25
done
for policy in $(find /sys/devices/system/cpu/cpufreq/policy*/ -name energy_performance_preference)
do
EPP=$(get_setting system.power.epp)
if [ -z "${EPP}" ]
then
EPP="performance"
set_setting system.power.epp ${EPP}
fi
echo ${EPP} >${policy} 2>/dev/null
done
fi
}

View file

@ -1,12 +1,9 @@
#!/bin/sh
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
# Minimal OS variable loading for performance
. /etc/profile.d/001-functions
CPU_VENDOR=$(cpu_vendor)
case ${CPU_VENDOR} in
AuthenticAMD)
tocon "Configuring system TDP..."
@ -18,32 +15,4 @@ case ${CPU_VENDOR} in
fi
/usr/bin/overclock boot
;;
GenuineIntel)
tocon "Configuring system EPP..."
###
### Enable dynamic boost.
###
if [ -f "/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost" ]
then
echo 1 >/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost
fi
###
### Energy Performance Preference isn't writeable if pstates are in
### active mode.
###
if [ -f "/sys/devices/system/cpu/intel_pstate/status" ]
then
echo passive >/sys/devices/system/cpu/intel_pstate/status
fi
EPP=$(get_setting system.power.epp)
if [ ! -z ${EPP} ]
then
/usr/bin/set_epp
fi
;;
esac

View file

@ -15,17 +15,38 @@ then
PROFILE=$(get_setting system.power.epp)
if [ -z "${PROFILE}" ]
then
PROFILE="balance_performance"
PROFILE="performance"
set_setting system.power.epp ${PROFILE}
fi
else
PROFILE=$1
fi
CPU_VENDOR=$(cpu_vendor)
case ${PROFILE} in
*)
for POLICY in $(find /sys/devices/system/cpu/cpufreq -name policy[0-9]*)
do
echo ${PROFILE} >${POLICY}/energy_performance_preference 2>/dev/null
done
case ${CPU_VENDOR} in
AuthenticAMD)
PSTATE="amd_pstate"
STATUS="active"
;;
GenuineIntel)
PSTATE="intel_pstate"
STATUS="passive"
;;
esac
if [ -f "/sys/devices/system/cpu/${PSTATE}/status" ]
then
echo ${STATUS} >/sys/devices/system/cpu/${PSTATE}/status
while [ ! -f /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference ]
do
sleep .25
done
case ${PROFILE} in
*)
for POLICY in $(find /sys/devices/system/cpu/cpufreq -name policy[0-9]*)
do
echo ${PROFILE} >${POLICY}/energy_performance_preference 2>/dev/null
done
;;
esac
fi

View file

@ -3,7 +3,7 @@
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
PKG_NAME="emulationstation"
PKG_VERSION="cc2ef90"
PKG_VERSION="6c712ff"
PKG_GIT_CLONE_BRANCH="main"
PKG_REV="1"
PKG_ARCH="any"

View file

@ -14,7 +14,7 @@
esac
# kernel command line
EXTRA_CMDLINE="quiet console=tty0 ssh consoleblank=0 systemd.show_status=0 loglevel=0 panic=20 intel_pstate=active amd_pstate=active amd_pstate.shared_mem=1 amdgpu.dpm=1"
EXTRA_CMDLINE="quiet console=tty0 ssh consoleblank=0 systemd.show_status=0 loglevel=0 panic=20 intel_pstate=passive amd_pstate=active amd_pstate.shared_mem=1 amdgpu.dpm=1"
# Partition label
PARTITION_TABLE="msdos"

View file

@ -31,7 +31,7 @@
BOOTLOADER="u-boot"
PARTITION_TABLE="gpt"
UBOOT_LABEL="uboot"
TRUST_LABEL="trust"
TRUST_LABEL="resource"
DEVICE_DTB=("rk3566-rg353p-linux" "rk3566-rg353v-linux" "rk3566-rg353m-linux" "rk3566-rg503-linux" "rk3566-rk2023-linux" "rk3566-rgb30-linux")
UBOOT_DTB="rk3566"
UBOOT_CONFIG="rk3568_defconfig"

View file

@ -80,19 +80,19 @@ STORAGE_PART_START=$(( ${SYSTEM_PART_END} + 1 ))
STORAGE_PART_END=$(( ${STORAGE_PART_START} + (${STORAGE_SIZE} * 1024 * 1024 / 512) - 1 ))
if [ "${PARTITION_TABLE}" = "gpt" ]; then
echo "image: Create boot partition."
echo "image: Create GPT boot partition."
parted -s "${DISK}" -a min unit s mkpart boot fat32 ${SYSTEM_PART_START} ${SYSTEM_PART_END}
else
echo "image: Create primary partition."
echo "image: Create MBR boot partition."
parted -s "${DISK}" -a min unit s mkpart primary fat32 ${SYSTEM_PART_START} ${SYSTEM_PART_END}
parted -s "${DISK}" set 1 boot on
fi
if [ "${PARTITION_TABLE}" = "gpt" ]; then
echo "image: Create storage partition."
echo "image: Create GPT storage partition."
parted -s "${DISK}" -a min unit s mkpart storage ext4 ${STORAGE_PART_START} ${STORAGE_PART_END}
else
echo "image: Create primary partition."
echo "image: Create MBR Storage partition."
parted -s "${DISK}" -a min unit s mkpart primary ext4 ${STORAGE_PART_START} ${STORAGE_PART_END}
fi
sync