mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Add pcvSetVoltageEnabled and pcvGetVoltageEnabled (#208)
* Add pcvSetVoltageEnabled and pcvGetVoltageEnabled
This commit is contained in:
parent
8767ea798b
commit
a7577f7b56
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user