#!/bin/sh

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2024 ArchR (https://github.com/archr-linux/Arch-R)

# Minimal OS variable loading for performance
. /etc/profile.d/001-functions

if [ -z "${GPU_FREQ}" ]; then
  . /etc/profile
fi

# Set max gpu freq
case $1 in
  0)
    echo 587000000 > $GPU_FREQ/max_freq
    set_setting gpu-overclock-speed 0
  ;;
  650)
    echo 650000000 > $GPU_FREQ/max_freq
    set_setting gpu-overclock-speed 650
  ;;
  700)
    echo 700000000 > $GPU_FREQ/max_freq
    set_setting gpu-overclock-speed 700
  ;;
  750)
    echo 750000000 > $GPU_FREQ/max_freq
    set_setting gpu-overclock-speed 750
  ;;
  800)
    echo 800000000 > $GPU_FREQ/max_freq
    set_setting gpu-overclock-speed 800
  ;;
esac
