Rockchip: consolidate cputemp and gputemp

Use thermal zone type to determin how to read cpu or gpu temp
This commit is contained in:
Jonas Karlman
2024-09-08 07:47:01 +00:00
committed by Christian Hewitt
parent 1d6c4baa27
commit 3cce144b5e
4 changed files with 35 additions and 18 deletions

View File

@@ -1,8 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
echo "$(($TEMP / 1000)) C"

View File

@@ -1,8 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone1/temp)"
echo "$(($TEMP / 1000)) C"

View File

@@ -4,5 +4,18 @@
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
# try to find temperature of cpu
for thermal_zone in /sys/devices/virtual/thermal/thermal_zone*; do
[ -d "$thermal_zone" ] || continue
if [[ "$(cat $thermal_zone/type)" =~ '(cpu|soc)-thermal' ]]; then
TEMP="$(cat $thermal_zone/temp)"
break
fi
done
# fallback to highest temperature
if [ -z "$TEMP" ]; then
TEMP=$(cat /sys/devices/virtual/thermal/thermal_zone*/temp | sort -n | tail -1)
fi
echo "$(($TEMP / 1000)) C"

View File

@@ -1 +0,0 @@
cputemp

View File

@@ -0,0 +1,21 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
# try to find temperature of gpu
for thermal_zone in /sys/devices/virtual/thermal/thermal_zone*; do
[ -d "$thermal_zone" ] || continue
if [ "$(cat $thermal_zone/type)" = "gpu-thermal" ]; then
TEMP="$(cat $thermal_zone/temp)"
break
fi
done
# fallback to highest temperature
if [ -z "$TEMP" ]; then
TEMP=$(cat /sys/devices/virtual/thermal/thermal_zone*/temp | sort -n | tail -1)
fi
echo "$(($TEMP / 1000)) C"