Skip to content

Commit

Permalink
Handle 8.0.0 changes to pcv
Browse files Browse the repository at this point in the history
  • Loading branch information
p-sam committed Apr 21, 2019
1 parent 93d27d6 commit f393d46
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions src/clocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ void Clocks::Initialize()
{
Result rc = 0;

rc = pcvInitialize();
ASSERT_RESULT_OK(rc, "pcvInitialize");
if(hosversionAtLeast(8,0,0)) {
rc = clkrstInitialize();
ASSERT_RESULT_OK(rc, "pcvInitialize");
} else {
rc = pcvInitialize();
ASSERT_RESULT_OK(rc, "pcvInitialize");
}

rc = apmExtInitialize();
ASSERT_RESULT_OK(rc, "apmExtInitialize");
Expand All @@ -50,7 +55,11 @@ void Clocks::Initialize()

void Clocks::Exit()
{
pcvExit();
if(hosversionAtLeast(8,0,0)) {
pcvExit();
} else {
clkrstExit();
}
apmExtExit();
psmExit();
}
Expand Down Expand Up @@ -149,15 +158,43 @@ ClockProfile Clocks::GetCurrentProfile()

void Clocks::SetHz(ClockModule module, std::uint32_t hz)
{
Result rc = pcvSetClockRate(Clocks::GetPcvModule(module), hz);
ASSERT_RESULT_OK(rc, "pcvSetClockRate");
Result rc = 0;

if(hosversionAtLeast(8,0,0)) {
ClkrstSession session = {0};

rc = clkrstOpenSession(&session, Clocks::GetPcvModule(module));
ASSERT_RESULT_OK(rc, "clkrstOpenSession");

rc = clkrstSetClockRate(&session, hz);
ASSERT_RESULT_OK(rc, "clkrstSetClockRate");

clkrstCloseSession(&session);
} else {
rc = pcvSetClockRate(Clocks::GetPcvModule(module), hz);
ASSERT_RESULT_OK(rc, "pcvSetClockRate");
}
}

std::uint32_t Clocks::GetCurrentHz(ClockModule module)
{
Result rc = 0;
std::uint32_t hz = 0;
Result rc = pcvGetClockRate(Clocks::GetPcvModule(module), &hz);
ASSERT_RESULT_OK(rc, "pcvGetClockRate");

if(hosversionAtLeast(8,0,0)) {
ClkrstSession session = {0};

rc = clkrstOpenSession(&session, Clocks::GetPcvModule(module));
ASSERT_RESULT_OK(rc, "clkrstOpenSession");

rc = clkrstGetClockRate(&session, &hz);
ASSERT_RESULT_OK(rc, "clkrstSetClockRate");

clkrstCloseSession(&session);
} else {
rc = pcvGetClockRate(Clocks::GetPcvModule(module), &hz);
ASSERT_RESULT_OK(rc, "pcvGetClockRate");
}

return hz;
}
Expand Down

0 comments on commit f393d46

Please sign in to comment.