Skip to content

Commit

Permalink
cpu: Grep CPU max and min frequencies from cpuinfo
Browse files Browse the repository at this point in the history
Signed-off-by: Rem01Gaming <Rem01_Gaming@proton.me>
  • Loading branch information
Rem01Gaming committed Oct 15, 2024
1 parent 1f06ae7 commit 82a053a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions share/utils/cpu/cpu_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ elif [[ $soc == Qualcomm ]]; then
source $PREFIX/share/origami-kernel/utils/cpu/qcom_cpubus.sh
fi

# https://askubuntu.com/questions/1064269/cpufrequtils-available-frequencies
intel_scaling_available_frequencies() {
NumSteps=$(cat /sys/devices/system/cpu/intel_pstate/num_pstates)
MinFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq)
MaxFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq)
MinFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq)
MaxFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
LastFreq=$MinFreq
StepRate=$((($MaxFreq - $MinFreq) / $NumSteps))
for ((n = 0; n <= $NumSteps; n++)); do
Expand Down Expand Up @@ -117,14 +118,7 @@ cpu_set_freq() {
esac
cpu_cluster_handle $cluster_selected
max_min=$1

if [ $soc == "Intel" ]; then
local available_freq="$(intel_scaling_available_frequencies)"
else
local available_freq="$(cat /sys/devices/system/cpu/cpufreq/policy${first_cpu_oncluster}/scaling_available_frequencies)"
fi

local freq=$(fzf_select "$available_freq" "Select $max_min CPU freq for $cluster_selected cluster: ")
local freq=$(fzf_select "$(cat /sys/devices/system/cpu/cpufreq/policy${first_cpu_oncluster}/scaling_available_frequencies)" "Select $max_min CPU freq for $cluster_selected cluster: ")
command2db cpu.$cluster_selected.${max_min}_freq "cpu_set_freq -exec $freq $cluster_selected $max_min" FALSE
fi

Expand All @@ -145,7 +139,14 @@ cpu_set_freq() {
max_min=$3
else
max_min=$1
local freq=$(fzf_select "$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies)" "Select $max_min CPU frequency: ")

if [[ $soc == "Intel" ]]; then
local available_freq="$(intel_scaling_available_frequencies)"
else
local available_freq="$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies)"
fi

local freq=$(fzf_select "$available_freq" "Select $max_min CPU frequency: ")
command2db cpu.${max_min}_freq "cpu_set_freq -exec $freq $max_min" FALSE
fi

Expand Down

0 comments on commit 82a053a

Please sign in to comment.