#!/bin/sh
set -e

TIME=$1

[ -z "$TIME" ] && TIME=0.001

UID=$(id -u)
if [ "$UID" -ne "0" ]; then
    echo "$0 must be run as root."
    exit 1
fi

cd /sys/class/drm/card0/device

echo manual > power_dpm_force_performance_level

while sleep "$TIME"; do
    echo 0 > pp_dpm_mclk
    sleep "$TIME"
    echo 1 > pp_dpm_mclk
done

