mirror of
https://github.com/switchbrew/libnx.git
synced 2025-08-06 00:19:22 +02:00
Add GetPossibleClockRates method for pcv and clkrst
This commit is contained in:
parent
94cfa2be1c
commit
ae491ce57b
@ -27,3 +27,4 @@ Result clkrstOpenSession(ClkrstSession* session_out, PcvModuleId module_id, u32
|
||||
void clkrstCloseSession(ClkrstSession* session);
|
||||
Result clkrstSetClockRate(ClkrstSession* session, u32 hz);
|
||||
Result clkrstGetClockRate(ClkrstSession* session, u32 *out_hz);
|
||||
Result clkrstGetPossibleClockRates(ClkrstSession *session, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count);
|
||||
|
@ -191,6 +191,13 @@ typedef enum {
|
||||
PcvModuleId_EXTPERIPH2 = 0x40000057,
|
||||
} PcvModuleId;
|
||||
|
||||
// Clock list type returned by GetPossibleClockRates
|
||||
typedef enum {
|
||||
PcvClockRatesListType_Invalid = 0,
|
||||
PcvClockRatesListType_Discrete = 1,
|
||||
PcvClockRatesListType_Range = 2,
|
||||
} PcvClockRatesListType;
|
||||
|
||||
/// Initialize pcv.
|
||||
Result pcvInitialize(void);
|
||||
|
||||
@ -210,3 +217,5 @@ Result pcvSetClockRate(PcvModule module, u32 hz);
|
||||
Result pcvSetVoltageEnabled(u32 power_domain, bool state);
|
||||
/// Only available on [1.0.0-7.0.1].
|
||||
Result pcvGetVoltageEnabled(bool *isEnabled, u32 power_domain);
|
||||
/// Only available on [1.0.0-7.0.1].
|
||||
Result pcvGetPossibleClockRates(PcvModule module, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count);
|
||||
|
@ -44,3 +44,20 @@ Result clkrstSetClockRate(ClkrstSession* session, u32 hz) {
|
||||
Result clkrstGetClockRate(ClkrstSession* session, u32 *out_hz) {
|
||||
return serviceDispatchOut(&session->s, 8, *out_hz);
|
||||
}
|
||||
|
||||
Result clkrstGetPossibleClockRates(ClkrstSession *session, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count) {
|
||||
struct {
|
||||
s32 type;
|
||||
s32 count;
|
||||
} out;
|
||||
|
||||
Result rc = serviceDispatchInOut(&session->s, 10, max_count, out,
|
||||
.buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcAutoSelect, },
|
||||
.buffers = { { rates, max_count * sizeof(u32) }, }
|
||||
);
|
||||
|
||||
if (R_SUCCEEDED(rc) && out_type) *out_type = out.type;
|
||||
if (R_SUCCEEDED(rc) && out_count) *out_count = out.count;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -94,3 +94,28 @@ Result pcvGetVoltageEnabled(bool *isEnabled, u32 power_domain) {
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result pcvGetPossibleClockRates(PcvModule module, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count) {
|
||||
if(hosversionAtLeast(8,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
const struct {
|
||||
PcvModule module;
|
||||
s32 max_count;
|
||||
} in = { module, max_count };
|
||||
|
||||
struct {
|
||||
s32 type;
|
||||
s32 count;
|
||||
} out;
|
||||
|
||||
Result rc = serviceDispatchInOut(&g_pcvSrv, 5, in, out,
|
||||
.buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcPointer, },
|
||||
.buffers = { { rates, max_count * sizeof(u32) }, }
|
||||
);
|
||||
|
||||
if (R_SUCCEEDED(rc) && out_type) *out_type = out.type;
|
||||
if (R_SUCCEEDED(rc) && out_count) *out_count = out.count;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user