Skip to content

Commit

Permalink
feat: Add power readings for SI, CI, VI, AI
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualEhrmanntraut committed Nov 11, 2024
1 parent ab2a9c8 commit ff08956
Show file tree
Hide file tree
Showing 7 changed files with 393 additions and 103 deletions.
24 changes: 22 additions & 2 deletions SMCRadeonSensors/AMDCommon.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2023-2024 ChefKiss. Licensed under the Thou Shalt Not Profit License version 1.5. See LICENSE for
// details.
// Copyright © 2023-2024 ChefKiss. Licensed under the Thou Shalt Not Profit License version 1.5.
// See LICENSE for details.

#pragma once
#include <Headers/kern_util.hpp>
Expand All @@ -25,3 +25,23 @@ constexpr UInt32 CUR_TEMP_RANGE_SEL = 0x80000;
constexpr UInt32 mmCG_MULT_THERMAL_STATUS_THM9 = 0x5A;
constexpr UInt32 mmCG_MULT_THERMAL_STATUS_THM11 = 0x5F;
#define GET_THERMAL_STATUS_CTF_TEMP(v) (((v) & 0x3FE00) >> 9)

constexpr UInt32 AMDGPU_MAX_USEC_TIMEOUT = 100000;

constexpr UInt32 MP_BASE_SMU9 = 0x16000;
constexpr UInt32 mmMP1_SMN_C2PMSG_66 = 0x282;
constexpr UInt32 mmMP1_SMN_C2PMSG_82 = 0x292;
constexpr UInt32 mmMP1_SMN_C2PMSG_90 = 0x29A;

constexpr UInt32 mmSMC_MESSAGE_0_SMU7 = 0x94;
constexpr UInt32 mmSMC_RESP_0_SMU7 = 0x95;
constexpr UInt32 SMC_RESP_0_MASK_SMU7 = 0xFFFF;
constexpr UInt32 mmSMC_MSG_ARG_0_SMU7 = 0xA4;

constexpr UInt32 ixSMU_PM_STATUS_95 = 0x3FF7C;

constexpr UInt32 PPSMC_MSG_PmStatusLogStart_SMU7 = 0x170;
constexpr UInt32 PPSMC_MSG_PmStatusLogSample_SMU7 = 0x171;
constexpr UInt32 PPSMC_MSG_GetCurrPkgPwr_SMU7 = 0x282;

constexpr UInt32 PPSMC_MSG_GetCurrPkgPwr_SMU9 = 0x61;
12 changes: 9 additions & 3 deletions SMCRadeonSensors/KeyImplementations.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// Copyright © 2023-2024 ChefKiss. Licensed under the Thou Shalt Not Profit License version 1.5. See LICENSE for
// details.
// Copyright © 2023-2024 ChefKiss. Licensed under the Thou Shalt Not Profit License version 1.5.
// See LICENSE for details.

#include "KeyImplementations.hpp"

SMC_RESULT RGPUTempValue::readAccess() {
auto value = this->provider->getTemperature(this->index);
*reinterpret_cast<UInt16 *>(this->data) = VirtualSMCAPI::encodeIntSp(SmcKeyTypeSp78, value);
*reinterpret_cast<UInt16 *>(this->data) = VirtualSMCAPI::encodeIntSp(this->type, value);
return SmcSuccess;
}

SMC_RESULT RGPUPowerValue::readAccess() {
auto value = this->provider->getPower(this->index);
*reinterpret_cast<UInt16 *>(data) = VirtualSMCAPI::encodeSp(this->type, static_cast<double>(value));
return SmcSuccess;
}
7 changes: 7 additions & 0 deletions SMCRadeonSensors/KeyImplementations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ class RGPUTempValue : public RadeonSMCValue {
protected:
SMC_RESULT readAccess() APPLE_KEXT_OVERRIDE;
};

class RGPUPowerValue : public RadeonSMCValue {
using RadeonSMCValue::RadeonSMCValue;

protected:
SMC_RESULT readAccess() APPLE_KEXT_OVERRIDE;
};
Loading

0 comments on commit ff08956

Please sign in to comment.