#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)

. /etc/profile.d/001-functions

### Set the default device configuration
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_BRIGHTNESS="hardware"
EOF

CPU_INFO=$(awk 'BEGIN {FS=":"} /model name/ {print $2; exit}' /proc/cpuinfo)
case ${CPU_INFO} in
  (*AMD*3050*)
    cat <<EOF >>/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="6w"
DEVICE_TDP_RANGE=(2.5w 4.5w 6w 9w 12w 15w 18w 20w 22w 25w)
EOF
  ;;
  (*AMD*55*U*)
    cat <<EOF >>/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="15w"
DEVICE_TDP_RANGE=(2.5w 4.5w 6w 9w 12w 15w 18w 20w 22w 25w)
EOF
  ;;
  (*AMD*68*U*)
    cat <<EOF >>/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="15w"
DEVICE_TDP_RANGE=(2.5w 4.5w 6w 9w 12w 15w 18w 22w 24w 28w)
EOF
  ;;
  (*AMD*78*U*)
    cat <<EOF >>/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="15w"
DEVICE_TDP_RANGE=(2.5w 4.5w 6w 9w 12w 15w 18w 22w 24w 28w 30w 35w)
EOF
  ;;
  (*)
    cat <<EOF >>/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="15w"
DEVICE_TDP_RANGE=(2.5w 4.5w 6w 9w 12w 15w 18w 22w 25w)
EOF
  ;;
esac
