Add pcvSetVoltageEnabled and pcvGetVoltageEnabled (#208)

* Add pcvSetVoltageEnabled and pcvGetVoltageEnabled
This commit is contained in:
pixel-stuck 2018-11-19 10:37:59 -05:00 committed by yellows8
parent 8767ea798b
commit a7577f7b56
2 changed files with 77 additions and 0 deletions

View File

@ -18,3 +18,6 @@ void pcvExit(void);
Result pcvGetClockRate(PcvModule module, u32 *out_hz);
Result pcvSetClockRate(PcvModule module, u32 hz);
Result pcvSetVoltageEnabled(bool state, u32 voltage);
Result pcvGetVoltageEnabled(bool *isEnabled, u32 voltage);

View File

@ -104,3 +104,77 @@ Result pcvGetClockRate(PcvModule module, u32 *out_hz) {
return rc;
}
Result pcvSetVoltageEnabled(bool state, u32 voltage) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u8 state;
u32 voltage;
} *raw;
raw = serviceIpcPrepareHeader(&g_pcvSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 8;
raw->state = (u8)state;
raw->voltage = voltage;
Result rc = serviceIpcDispatch(&g_pcvSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(&g_pcvSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result pcvGetVoltageEnabled(bool *isEnabled, u32 voltage) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u32 voltage;
} *raw;
raw = serviceIpcPrepareHeader(&g_pcvSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 9;
raw->voltage = voltage;
Result rc = serviceIpcDispatch(&g_pcvSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
u8 isEnabled;
} *resp;
serviceIpcParse(&g_pcvSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
if(R_SUCCEEDED(rc) && isEnabled) {
*isEnabled = (bool)resp->isEnabled;
}
}
return rc;
}