From 9037d4cea45f2c4b1bacefded6402acc2beb755b Mon Sep 17 00:00:00 2001 From: p-sam Date: Wed, 24 Apr 2019 20:12:48 +0200 Subject: [PATCH] Sync up with clkrst libnx API changes --- src/clocks.cpp | 20 ++++++++++++++++++-- src/clocks.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/clocks.cpp b/src/clocks.cpp index 529e459e..c273d65a 100644 --- a/src/clocks.cpp +++ b/src/clocks.cpp @@ -118,6 +118,22 @@ PcvModule Clocks::GetPcvModule(ClockModule clockmodule) { return (PcvModule)0; } +PcvModuleId Clocks::GetPcvModuleId(ClockModule clockmodule) { + switch(clockmodule) + { + case ClockModule_CPU: + return PcvModuleId_CpuBus; + case ClockModule_GPU: + return PcvModuleId_GPU; + case ClockModule_MEM: + return PcvModuleId_EMC; + default: + ERROR_THROW("No such ClockModule: %u", clockmodule); + } + + return (PcvModuleId)0; +} + std::uint32_t Clocks::ResetToStock() { std::uint32_t mode = 0; Result rc = apmExtGetPerformanceMode(&mode); @@ -163,7 +179,7 @@ void Clocks::SetHz(ClockModule module, std::uint32_t hz) if(hosversionAtLeast(8,0,0)) { ClkrstSession session = {0}; - rc = clkrstOpenSession(&session, Clocks::GetPcvModule(module)); + rc = clkrstOpenSession(&session, Clocks::GetPcvModuleId(module), 3); ASSERT_RESULT_OK(rc, "clkrstOpenSession"); rc = clkrstSetClockRate(&session, hz); @@ -184,7 +200,7 @@ std::uint32_t Clocks::GetCurrentHz(ClockModule module) if(hosversionAtLeast(8,0,0)) { ClkrstSession session = {0}; - rc = clkrstOpenSession(&session, Clocks::GetPcvModule(module)); + rc = clkrstOpenSession(&session, Clocks::GetPcvModuleId(module), 3); ASSERT_RESULT_OK(rc, "clkrstOpenSession"); rc = clkrstGetClockRate(&session, &hz); diff --git a/src/clocks.h b/src/clocks.h index cbb86ff5..0c9ae90d 100644 --- a/src/clocks.h +++ b/src/clocks.h @@ -45,6 +45,7 @@ class Clocks protected: static PcvModule GetPcvModule(ClockModule clockmodule); + static PcvModuleId GetPcvModuleId(ClockModule clockmodule); static std::uint32_t GetNearestHz(ClockModule module, std::uint32_t inHz); static void GetList(ClockModule module, std::uint32_t **outClocks, size_t *outClockCount); static std::uint32_t GetMaxAllowedHz(ClockModule module, ClockProfile profile);