# HyperFire Kernel Tweak

# Initialization
on property:sys.boot_completed=1
   # Set default profile on first boot
   exec u:r:init:s0 root root -- /init.hyperfire.sh
   exec u:r:su:s0 root root -- /init.hyperfire.sh
   # Enable HyperFire support
   setprop hyperfire.support 1
   # Add kernel name
   setprop persist.hyprefire.kernel HypreFire

# Balance (default profile)
on property:persist.hyperfire.profile=0
    # CPU
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor electron
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 652800
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 1958400
    write /sys/module/msm_performance/parameters/touchboost 0

    # GPU
    write /sys/class/kgsl/kgsl-3d0/devfreq/governor msm-adreno-tz
    write /sys/class/kgsl/kgsl-3d0/devfreq/min_freq 133000000
    write /sys/class/kgsl/kgsl-3d0/max_gpuclk 650000000
    write /sys/module/adreno_idler/parameters/adreno_idler_active 0

    # Storage
    write /sys/block/mmcblk0/queue/scheduler maple

    # Misc
    write /sys/kernel/sched/arch_power 1
    write /sys/kernel/fast_charge/force_fast_charge 1

# Performance (based on DrunkSauce Lite)
on property:persist.hyperfire.profile=1
    # CPU
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor interactive
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 652000
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 2016000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load 80
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay 0
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate 40000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq 960000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_slack 480000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads 80 460800:70 600000:99
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time 50000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/boost 1
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/align_windows 0
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis 0
    write /sys/module/msm_performance/parameters/touchboost 0

    # GPU
    write /sys/class/kgsl/kgsl-3d0/devfreq/governor msm-adreno-tz
    write /sys/class/kgsl/kgsl-3d0/devfreq/min_freq 133000000
    write /sys/class/kgsl/kgsl-3d0/max_gpuclk 650000000
    write /sys/module/adreno_idler/parameters/adreno_idler_active 0

    # Storage
    write /sys/block/mmcblk0/queue/scheduler bfq

    # Misc
    write /sys/kernel/sched/arch_power 0
    write /sys/kernel/fast_charge/force_fast_charge 1

# Battery
on property:persist.hyperfire.profile=2
    # CPU
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor relaxed
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 652000
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 1689000
    write /sys/devices/system/cpu/cpu0/cpufreq/relaxed/boost_count 6
    write /sys/devices/system/cpu/cpu0/cpufreq/relaxed/boost_ceiling 12
    write /sys/devices/system/cpu/cpu0/cpufreq/relaxed/freq_step 6
    write /sys/devices/system/cpu/cpu0/cpufreq/relaxed/down_threshold 70
    write /sys/devices/system/cpu/cpu0/cpufreq/relaxed/down_threshold_suspended 85
    write /sys/devices/system/cpu/cpu0/cpufreq/relaxed/up_threshold 75
    write /sys/module/msm_performance/parameters/touchboost 0

    # GPU
    write /sys/class/kgsl/kgsl-3d0/devfreq/governor msm-adreno-tz
    write /sys/class/kgsl/kgsl-3d0/devfreq/min_freq 133000000
    write /sys/class/kgsl/kgsl-3d0/max_gpuclk 400000000
    write /sys/module/adreno_idler/parameters/adreno_idler_active 1

    # Storage
    write /sys/block/mmcblk0/queue/scheduler noop

    # Misc
    write /sys/kernel/sched/arch_power 1
    write /sys/kernel/fast_charge/force_fast_charge 1

# Gaming
on property:persist.hyperfire.profile=3
    # CPU
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor interactive
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 652000
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 2016000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load 80
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay 0
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate 40000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq 960000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_slack 480000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads 80 460800:70 600000:99
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time 50000
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/boost 1
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/align_windows 0
    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis 0
    write /sys/module/msm_performance/parameters/touchboost 0

    # GPU
    write /sys/class/kgsl/kgsl-3d0/devfreq/governor performance
    write /sys/class/kgsl/kgsl-3d0/devfreq/min_freq 133000000
    write /sys/class/kgsl/kgsl-3d0/max_gpuclk 650000000
    write /sys/module/adreno_idler/parameters/adreno_idler_active 0

    # Storage
    write /sys/block/mmcblk0/queue/scheduler deadline

    # Misc
    write /sys/kernel/sched/arch_power 0
    write /sys/kernel/fast_charge/force_fast_charge 1
    echo "2" /sys/android_touch/doubletap2wake

