/*
 * Copyright 2024 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef HARDWAREPOWERCONTROL_H
#define HARDWAREPOWERCONTROL_H

#include <QObject>
#include <QDir>

#define GPU_DEVICES_PATH        "/sys/class/drm/card0/device/"
#define GPU_DEVICE_BASE_PATH    "/sys/class/devfreq/"
#define GPU_POWER_DPM_STATE     "power_dpm_state"
#define GPU_POWER_GOVERNOR      "governor"
#define GPU_POWER_DPM_LEVEL     "power_dpm_force_performance_level"

#define INTEL_AUDIO_PATH     "/sys/module/snd_hda_intel/parameters/"
#define INTEL_AUDIO_FILE     "power_save"

#define PCIE_ASPM_PATH       "/sys/module/pcie_aspm/parameters/"
#define PCIE_ASPM_FILE       "policy"

class HardwarePowerControl : public QObject
{
    Q_OBJECT
public:
    explicit HardwarePowerControl(QObject *parent = nullptr);
    ~HardwarePowerControl();

    void setGpuFrequencyMode(const int policy);
    void setAudioMode(const int policy);
    void setPcieAspmMode(const int policy);

private:
    QStringList m_gpuPowerDpmState = {"performance", "balanced", "battery"};
    QStringList m_gpuPowerDpmLevel = {"high", "auto", "low"};
    QStringList m_intelAudioMode = {"0", "1", "1"};
    QStringList m_gpuPowerGovernor = {"performance", "simple_ondemand", "simple_ondemand"};

    void initGpuFrequencyState();
    void initGpuFrequencyLevel();
    void initIntelAudioMode();

signals:

};

#endif // HARDWAREPOWERCONTROL_H
