Merge pull request #1506 from fewtarius/dev

Rework scripts to enable configuring suspend mode, and to display panel info on RG353 devices.
This commit is contained in:
fewtarius 2023-06-02 16:59:30 -04:00 committed by GitHub
commit 45e263b29b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 192 additions and 277 deletions

View file

@ -0,0 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -4,9 +4,8 @@
. /etc/profile
# S3 sleep does not work on this device yet.
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -0,0 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -4,8 +4,8 @@
. /etc/profile
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi

View file

@ -0,0 +1 @@
Anbernic RG353P

View file

@ -1,38 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
cat <<EOF >/storage/.config/profile.d/001-deviceconfig
# Device Features
DEVICE_HAS_FAN=false
DEVICE_FAKE_JACKSENSE=false
DEVICE_VOLUMECTL=true
DEVICE_POWER_LED=false
DEVICE_AUDIO_MIXER="Master"
DEVICE_PLAYBACK_PATH_SPK="SPK"
DEVICE_PLAYBACK_PATH_HP="HP"
#DEVICE_HEADPHONE_DEV=""
DEVICE_BRIGHTNESS="128"
UI_SERVICE="emustation.service"
# Kernel Modules
DEVICE_INTERNAL_WIFI=true
DEVICE_WIFI_MODULE="8821cs"
# GPIOS
DEVICE_WIFI="0"
#DEVICE_LED=""
DEVICE_PWM_MOTOR="pwmchip1"
#DEVICE_PWM_FAN=""
#DEVICE_JACK=""
# FREQ governors
CPU_FREQ=("/sys/devices/system/cpu/cpufreq/policy0")
GPU_FREQ="/sys/devices/platform/fde60000.gpu/devfreq/fde60000.gpu"
DMC_FREQ="/sys/devices/platform/dmc/devfreq/dmc"
# Volume Keys
DEVICE_KEY_VOLUMEDOWN=114
DEVICE_KEY_VOLUMEUP=115
DEVICE_VOL_MODIFIER="BTN_MODE"
EOF

View file

@ -1,17 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
# Enable PWM for rumble and turn rumble off during startup.
echo 0 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/export
echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/period
echo 1 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/enable
echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/duty_cycle
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF

View file

@ -1,146 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
### Set a custom device so we don't clobber it.
set-audio set "CUSTOM (UNMANAGED)"
set-audio esset "Master"
cat <<EOF >/storage/.config/asound.conf
pcm.!default {
type plug
slave.pcm "softvol"
}
ctl.!default {
type hw
card 0
}
pcm.ddmix {
ipc_key 1024
type dmix
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
}
pcm.softvol {
type softvol
slave {
pcm "ddmix"
}
control {
name "Master"
card 0
}
}
EOF
if [ ! -e "/storage/.config/asound.state" ]
then
cat <<EOF >/storage/.config/asound.state
state.rockchiprk817co {
control.1 {
iface MIXER
name 'Playback Path'
value HP
comment {
access 'read write'
type ENUMERATED
count 1
item.0 OFF
item.1 RCV
item.2 SPK
item.3 HP
item.4 HP_NO_MIC
item.5 BT
item.6 SPK_HP
item.7 RING_SPK
item.8 RING_HP
item.9 RING_HP_NO_MIC
item.10 RING_SPK_HP
}
}
control.2 {
iface MIXER
name 'Capture MIC Path'
value 'MIC OFF'
comment {
access 'read write'
type ENUMERATED
count 1
item.0 'MIC OFF'
item.1 'Main Mic'
item.2 'Hands Free Mic'
item.3 'BT Sco Mic'
}
}
control.3 {
iface MIXER
name Master
value.0 109
value.1 109
comment {
access 'read write user'
type INTEGER
count 2
range '0 - 255'
tlv '0000000100000008ffffec1400000014'
dbmin -5100
dbmax 0
dbvalue.0 -2920
dbvalue.1 -2920
}
}
}
state.rockchiphdmi {
control.1 {
iface PCM
name 'Playback Channel Map'
value.0 0
value.1 0
value.2 0
value.3 0
value.4 0
value.5 0
value.6 0
value.7 0
comment {
access read
type INTEGER
count 8
range '0 - 36'
}
}
control.2 {
iface PCM
name ELD
value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
comment {
access 'read volatile'
type BYTES
count 128
}
}
control.3 {
iface PCM
name 'AUDIO MODE'
value 0
comment {
access 'read write volatile'
type INTEGER
count 1
range '0 - 2'
}
}
}
EOF
alsactl restore -f /storage/.config/asound.state
fi

View file

@ -1,16 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
# Configure default contrast saturation and hue values
for PROPERTY in brightness contrast saturation hue
do
MYVAL=$(get_setting display.${PROPERTY})
if [ -z "${MYVAL}" ]
then
MYVAL=$(drm_tool list | sed -n '/Connector: 133/,$p' | awk '/'${PROPERTY}'/ {print $5}')
fi
paneladj ${PROPERTY} ${MYVAL}
done

View file

@ -10,8 +10,10 @@ echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/period
echo 1 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/enable
echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/duty_cycle
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi
echo s2idle >/sys/power/mem_sleep

View file

@ -0,0 +1,18 @@
#!/bin/sh
ID=$(dmesg | grep "panel id:" | sed "s#^.*panel id: ##g")
case ${ID} in
"30 52")
ID="v1 (${ID})"
;;
"38 21")
ID="v2 (${ID})"
;;
*)
ID="Unknown"
;;
esac
if [ -n "${ID}" ]
then
echo "PANEL VERSION: ${ID}"
fi

View file

@ -10,8 +10,8 @@ echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/period
echo 1 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/enable
echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/duty_cycle
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi

View file

@ -0,0 +1,18 @@
#!/bin/sh
ID=$(dmesg | grep "panel id:" | sed "s#^.*panel id: ##g")
case ${ID} in
"30 52")
ID="v1"
;;
"38 21")
ID="v2"
;;
*)
ID="Unknown"
;;
esac
if [ -n "${ID}" ]
then
echo "PANEL VERSION: ${ID}"
fi

View file

@ -10,8 +10,10 @@ echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/period
echo 1 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/enable
echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/duty_cycle
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi
echo s2idle >/sys/power/mem_sleep

View file

@ -0,0 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -8,10 +8,8 @@
echo none > /sys/class/leds/blue\:/trigger
### Sleep is currently broken, so we'll disable it.
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=no
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi

View file

@ -9,3 +9,9 @@ then
echo 19000 > /sys/class/backlight/$(brightness device)/brightness
touch /storage/.quirks
fi
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -4,8 +4,8 @@
. /etc/profile
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi

View file

@ -4,8 +4,8 @@
. /etc/profile
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi

View file

@ -4,8 +4,8 @@
. /etc/profile
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi

View file

@ -6,3 +6,9 @@
# Enable verticle USB Port
echo host > /sys/kernel/debug/usb/fc000000.usb/mode
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -4,8 +4,10 @@
. /etc/profile
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode freeze
fi
echo s2idle >/sys/power/mem_sleep

View file

@ -4,8 +4,8 @@
. /etc/profile
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=freeze
EOF
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -0,0 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode mem
fi

View file

@ -42,3 +42,11 @@ then
set_setting system.cpugovernor schedutil
fi
### Configure suspend mode.
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -n "${MYSLEEPMODE}" ]
then
/usr/bin/setsuspendmode ${MYSLEEPMODE}
else
/usr/bin/setsuspendmode mem
fi

View file

@ -2,6 +2,22 @@
source /etc/profile
### Load quirks so we can display device specific info when it exists.
if [ -e "/sys/firmware/devicetree/base/model" ]
then
QUIRK_DEVICE=$(cat /sys/firmware/devicetree/base/model 2>/dev/null)
else
QUIRK_DEVICE="$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null) $(cat /sys/class/dmi/id/product_name 2>/dev/null)"
fi
QUIRK_DEVICE="$(echo ${QUIRK_DEVICE} | sed -e "s#[/]#-#g")"
info_quirks() {
for QUIRK in /usr/lib/autostart/quirks/"${QUIRK_DEVICE}"/info.d/${1}/*
do
"${QUIRK}" 2>/dev/null
done
}
### short version (for osd)
if test "$1" = "--short"
then
@ -131,3 +147,5 @@ case ${HW_ARCH} in
done
;;
esac
info_quirks

View file

@ -0,0 +1,10 @@
#!/bin/bash
. /etc/profile
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
AllowSuspend=yes
SuspendState=${1}
EOF
set_setting system.suspendmode ${1}

View file

@ -95,7 +95,7 @@ modules() {
}
quirks() {
for QUIRK in /usr/lib/autostart/quirks/"${QUIRK_DEVICE}"/sleep/${1}/*
for QUIRK in /usr/lib/autostart/quirks/"${QUIRK_DEVICE}"/sleep.d/${1}/*
do
"${QUIRK}" >/dev/null 2>&1
done

View file

@ -3,7 +3,7 @@
# Copyright (C) 2020-present Fewtarius
PKG_NAME="emulationstation"
PKG_VERSION="c0d963d"
PKG_VERSION="9b85d77"
PKG_GIT_CLONE_BRANCH="main"
PKG_REV="1"
PKG_ARCH="any"