sys-clk-OC

This commit is contained in:
KazushiM
2021-08-29 15:00:45 +08:00
parent 958de01e00
commit a4b4473809
261 changed files with 64395 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
/*
* --------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
* wrote this file. As long as you retain this notice you can do whatever you
* want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
#include <sysclk/apm.h>
SysClkApmConfiguration sysclk_g_apm_configurations[] = {
{0x00010000, 1020000000, 384000000, 1600000000},
{0x00010001, 1020000000, 768000000, 1600000000},
{0x00010002, 1224000000, 691200000, 1600000000},
{0x00020000, 1020000000, 230400000, 1600000000},
{0x00020001, 1020000000, 307200000, 1600000000},
{0x00020002, 1224000000, 230400000, 1600000000},
{0x00020003, 1020000000, 307000000, 1331200000},
{0x00020004, 1020000000, 384000000, 1331200000},
{0x00020005, 1020000000, 307200000, 1065600000},
{0x00020006, 1020000000, 384000000, 1065600000},
{0x92220007, 1020000000, 460800000, 1600000000},
{0x92220008, 1020000000, 460800000, 1331200000},
{0x92220009, 1963500000, 76800000, 1600000000},
{0x9222000A, 1963500000, 76800000, 1331200000},
{0x9222000B, 1020000000, 76800000, 1600000000},
{0x9222000C, 1020000000, 76800000, 1331200000},
{0, 0, 0, 0},
};

View File

@@ -0,0 +1,116 @@
/*
* --------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
* wrote this file. As long as you retain this notice you can do whatever you
* want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
#define NX_SERVICE_ASSUME_NON_DOMAIN
#include <sysclk/client/ipc.h>
#include <switch.h>
#include <string.h>
#include <stdatomic.h>
static Service g_sysclkSrv;
static atomic_size_t g_refCnt;
bool sysclkIpcRunning()
{
Handle handle;
bool running = R_FAILED(smRegisterService(&handle, smEncodeName(SYSCLK_IPC_SERVICE_NAME), false, 1));
if (!running)
{
smUnregisterService(smEncodeName(SYSCLK_IPC_SERVICE_NAME));
}
return running;
}
Result sysclkIpcInitialize(void)
{
Result rc = 0;
g_refCnt++;
if (serviceIsActive(&g_sysclkSrv))
return 0;
rc = smGetService(&g_sysclkSrv, SYSCLK_IPC_SERVICE_NAME);
if (R_FAILED(rc)) sysclkIpcExit();
return rc;
}
void sysclkIpcExit(void)
{
if (--g_refCnt == 0)
{
serviceClose(&g_sysclkSrv);
}
}
Result sysclkIpcGetAPIVersion(u32* out_ver)
{
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetApiVersion, *out_ver);
}
Result sysclkIpcGetVersionString(char* out, size_t len)
{
return serviceDispatch(&g_sysclkSrv, SysClkIpcCmd_GetVersionString,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = {{out, len}},
);
}
Result sysclkIpcGetCurrentContext(SysClkContext* out_context)
{
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetCurrentContext, *out_context);
}
Result sysclkIpcGetProfileCount(u64 tid, u8* out_count)
{
return serviceDispatchInOut(&g_sysclkSrv, SysClkIpcCmd_GetProfileCount, tid, *out_count);
}
Result sysclkIpcSetEnabled(bool enabled)
{
u8 enabledRaw = (u8)enabled;
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetEnabled, enabledRaw);
}
Result sysclkIpcSetOverride(SysClkModule module, u32 hz)
{
SysClkIpc_SetOverride_Args args = {
.module = module,
.hz = hz
};
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetOverride, args);
}
Result sysclkIpcGetProfiles(u64 tid, SysClkTitleProfileList* out_profiles)
{
return serviceDispatchInOut(&g_sysclkSrv, SysClkIpcCmd_GetProfiles, tid, *out_profiles);
}
Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles)
{
SysClkIpc_SetProfiles_Args args;
args.tid = tid;
memcpy(&args.profiles, profiles, sizeof(SysClkTitleProfileList));
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetProfiles, args);
}
Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues)
{
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetConfigValues, *out_configValues);
}
Result sysclkIpcSetConfigValues(SysClkConfigValueList* configValues)
{
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetConfigValues, *configValues);
}

View File

@@ -0,0 +1,77 @@
/*
* --------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
* wrote this file. As long as you retain this notice you can do whatever you
* want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
#include <stdint.h>
uint32_t sysclk_g_freq_table_mem_hz[] = {
// From Hekate Minerva module
665600000,
800000000,
1065600000,
1331200000,
1600000000,
1728000000,
1795200000,
1862400000,
1894400000,
1932800000,
1996800000,
2064000000,
2099200000,
2131200000,
0,
};
uint32_t sysclk_g_freq_table_cpu_hz[] = {
612000000,
714000000,
816000000,
918000000,
1020000000,
1122000000,
1224000000,
1326000000,
1428000000,
1581000000,
1683000000,
1785000000,
1887000000,
1963500000,
2091000000,
2193000000,
2295000000,
2397000000,
0,
};
uint32_t sysclk_g_freq_table_gpu_hz[] = {
76800000,
153600000,
230400000,
307200000,
384000000,
460800000,
537600000,
614400000,
691200000,
768000000,
844800000,
921600000,
998400000,
1075200000,
1152000000,
1228800000,
1267200000,
1305600000,
1344000000,
//1382400000,
//1420800000,
0,
};