mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Merge pull request #7682 from m4xw/OC
[LIBNX] Implement Over-/Downclocking and minor fixes
This commit is contained in:
commit
1caf10e1e9
@ -1679,6 +1679,10 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
|
||||
|
||||
SETTING_UINT("video_record_threads", &settings->uints.video_record_threads, true, video_record_threads, false);
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
SETTING_UINT("libnx_overclock", &settings->uints.libnx_overclock, true, SWITCH_DEFAULT_CPU_PROFILE, false);
|
||||
#endif
|
||||
|
||||
*size = count;
|
||||
|
||||
return tmp;
|
||||
@ -3133,6 +3137,12 @@ static bool config_load_file(const char *path, bool set_defaults,
|
||||
strlcpy(settings->arrays.menu_driver, "rgui", sizeof(settings->arrays.menu_driver));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
// Apply initial clocks
|
||||
extern void libnx_apply_overclock();
|
||||
libnx_apply_overclock();
|
||||
#endif
|
||||
|
||||
frontend_driver_set_sustained_performance_mode(settings->bools.sustained_performance_mode);
|
||||
recording_driver_update_streaming_url();
|
||||
|
||||
|
@ -446,6 +446,8 @@ typedef struct settings
|
||||
unsigned window_position_height;
|
||||
|
||||
unsigned video_record_threads;
|
||||
|
||||
unsigned libnx_overclock;
|
||||
} uints;
|
||||
|
||||
struct
|
||||
|
@ -13,6 +13,9 @@
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
#include <switch.h>
|
||||
#include "../../switch_performance_profiles.h"
|
||||
#include "../../configuration.h"
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <libtransistor/nx.h>
|
||||
#include <libtransistor/ipc_helpers.h>
|
||||
@ -70,18 +73,46 @@ static AppletHookCookie applet_hook_cookie;
|
||||
extern bool nxlink_connected;
|
||||
#endif
|
||||
|
||||
static void on_applet_hook(AppletHookType hook, void* param) {
|
||||
void libnx_apply_overclock() {
|
||||
const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES) / sizeof(SWITCH_CPU_PROFILES[1]);
|
||||
if (config_get_ptr()->uints.libnx_overclock >= 0 && config_get_ptr()->uints.libnx_overclock <= profiles_count)
|
||||
pcvSetClockRate(PcvModule_Cpu, SWITCH_CPU_SPEEDS_VALUES[config_get_ptr()->uints.libnx_overclock]);
|
||||
}
|
||||
|
||||
static void on_applet_hook(AppletHookType hook, void *param) {
|
||||
u32 performance_mode;
|
||||
AppletFocusState focus_state;
|
||||
|
||||
/* Exit request */
|
||||
if(hook == AppletHookType_OnExitRequest) {
|
||||
switch (hook)
|
||||
{
|
||||
case AppletHookType_OnExitRequest:
|
||||
RARCH_LOG("Got AppletHook OnExitRequest, exiting.\n");
|
||||
retroarch_main_quit();
|
||||
}
|
||||
/* Focus state*/
|
||||
else if (hook == AppletHookType_OnFocusState) {
|
||||
AppletFocusState focus_state = appletGetFocusState();
|
||||
RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state);
|
||||
break;
|
||||
|
||||
/* Focus state*/
|
||||
case AppletHookType_OnFocusState:
|
||||
focus_state = appletGetFocusState();
|
||||
RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state);
|
||||
platform_switch_has_focus = focus_state == AppletFocusState_Focused;
|
||||
if(!platform_switch_has_focus) {
|
||||
pcvSetClockRate(PcvModule_Cpu, 1020000000);
|
||||
} else {
|
||||
libnx_apply_overclock();
|
||||
}
|
||||
break;
|
||||
|
||||
/* Performance mode */
|
||||
case AppletHookType_OnPerformanceMode:
|
||||
// 0 == Handheld, 1 == Docked
|
||||
// Since CPU doesn't change we just re-apply
|
||||
performance_mode = appletGetPerformanceMode();
|
||||
libnx_apply_overclock();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,6 +242,8 @@ static void frontend_switch_deinit(void *data)
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
nifmExit();
|
||||
pcvSetClockRate(PcvModule_Cpu, 1020000000); // Always 1020 MHz, unless SDEV
|
||||
pcvExit();
|
||||
#if defined(SWITCH) && defined(NXLINK)
|
||||
socketExit();
|
||||
#endif
|
||||
@ -235,7 +268,7 @@ static void frontend_switch_deinit(void *data)
|
||||
#ifdef HAVE_LIBNX
|
||||
static void frontend_switch_exec(const char *path, bool should_load_game)
|
||||
{
|
||||
char game_path[PATH_MAX];
|
||||
char game_path[PATH_MAX-4];
|
||||
const char *arg_data[3];
|
||||
char error_string[200 + PATH_MAX];
|
||||
int args = 0;
|
||||
@ -623,16 +656,20 @@ static void frontend_switch_shutdown(bool unused)
|
||||
/* runloop_get_system_info isnt initialized that early.. */
|
||||
extern void retro_get_system_info(struct retro_system_info *info);
|
||||
|
||||
|
||||
static void frontend_switch_init(void *data)
|
||||
{
|
||||
|
||||
(void)data;
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
nifmInitialize();
|
||||
pcvInitialize();
|
||||
|
||||
appletLockExit();
|
||||
appletHook(&applet_hook_cookie, on_applet_hook, NULL);
|
||||
|
||||
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
||||
|
||||
#ifndef HAVE_OPENGL
|
||||
/* Init Resolution before initDefault */
|
||||
gfxInitResolution(1280, 720);
|
||||
@ -643,7 +680,10 @@ static void frontend_switch_init(void *data)
|
||||
gfxConfigureTransform(0);
|
||||
#endif /* HAVE_OPENGL */
|
||||
|
||||
appletInitializeGamePlayRecording();
|
||||
bool recording_supported = false;
|
||||
appletIsGamePlayRecordingSupported(&recording_supported);
|
||||
if(recording_supported)
|
||||
appletInitializeGamePlayRecording();
|
||||
|
||||
#ifdef NXLINK
|
||||
socketInitializeDefault();
|
||||
@ -788,6 +828,8 @@ static enum frontend_powerstate frontend_switch_get_powerstate(int *seconds, int
|
||||
case ChargerType_Charger:
|
||||
case ChargerType_Usb:
|
||||
return FRONTEND_POWERSTATE_CHARGING;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FRONTEND_POWERSTATE_NO_SOURCE;
|
||||
|
@ -15,6 +15,8 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
"调整 Switch 的屏幕亮度"
|
||||
)
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE,
|
||||
"CPU 超频"
|
||||
|
@ -15,6 +15,8 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
"Anpassen der Switch Bildschirmhelligkeit"
|
||||
)
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE,
|
||||
"CPU Übertakten"
|
||||
|
@ -15,6 +15,8 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
"Ajusta el brillo de la pantalla"
|
||||
)
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE,
|
||||
"CPU Overclock"
|
||||
|
@ -3,6 +3,8 @@ MSG_HASH(MENU_ENUM_LABEL_SWITCH_GPU_PROFILE,
|
||||
"switch_gpu_profile")
|
||||
MSG_HASH(MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
"switch_backlight_control")
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MSG_HASH(MENU_ENUM_LABEL_SWITCH_CPU_PROFILE,
|
||||
"switch_cpu_profile")
|
||||
#endif
|
||||
|
@ -15,6 +15,8 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
"Aumentar ou diminuir o brilho da tela do Switch"
|
||||
)
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE,
|
||||
"Overclock da CPU"
|
||||
|
@ -15,6 +15,8 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
"Increase or decrease the Switch screen brightness"
|
||||
)
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE,
|
||||
"CPU Overclock"
|
||||
|
63
lakka.h
63
lakka.h
@ -24,67 +24,6 @@
|
||||
#define LAKKA_UPDATE_DIR "/storage/.update/"
|
||||
#define LAKKA_CONNMAN_DIR "/storage/.cache/connman/"
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
static char* SWITCH_GPU_PROFILES[] = {
|
||||
"docked-overclock-3",
|
||||
"docked-overclock-2",
|
||||
"docked-overclock-1",
|
||||
"docked",
|
||||
"non-docked-overclock-5",
|
||||
"non-docked-overclock-4",
|
||||
"non-docked-overclock-3",
|
||||
"non-docked-overclock-2",
|
||||
"non-docked-overclock-1",
|
||||
"non-docked",
|
||||
"non-docked-underclock-1",
|
||||
"non-docked-underclock-2",
|
||||
"non-docked-underclock-3",
|
||||
};
|
||||
|
||||
static char* SWITCH_GPU_SPEEDS[] = {
|
||||
"998 Mhz",
|
||||
"921 Mhz",
|
||||
"844 Mhz",
|
||||
"768 Mhz",
|
||||
"691 Mhz",
|
||||
"614 Mhz",
|
||||
"537 Mhz",
|
||||
"460 Mhz",
|
||||
"384 Mhz",
|
||||
"307 Mhz",
|
||||
"230 Mhz",
|
||||
"153 Mhz",
|
||||
"76 Mhz"
|
||||
};
|
||||
|
||||
static int SWITCH_BRIGHTNESS[] = {
|
||||
10,
|
||||
20,
|
||||
30,
|
||||
40,
|
||||
50,
|
||||
60,
|
||||
70,
|
||||
80,
|
||||
90,
|
||||
100
|
||||
};
|
||||
|
||||
static char* SWITCH_CPU_PROFILES[] = {
|
||||
"overclock-4",
|
||||
"overclock-3",
|
||||
"overclock-2",
|
||||
"overclock-1",
|
||||
"default",
|
||||
};
|
||||
|
||||
static char* SWITCH_CPU_SPEEDS[] = {
|
||||
"1912 MHz",
|
||||
"1734 MHz",
|
||||
"1530 MHz",
|
||||
"1224 MHz",
|
||||
"1020 MHz"
|
||||
};
|
||||
#endif
|
||||
#include "switch_performance_profiles.h"
|
||||
|
||||
#endif
|
||||
|
@ -187,10 +187,13 @@ generic_deferred_push(deferred_push_core_content_dirs_subdir_list, DISPLAYLIST_
|
||||
generic_deferred_push(deferred_push_lakka_list, DISPLAYLIST_LAKKA)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
generic_deferred_push(deferred_push_switch_cpu_profile, DISPLAYLIST_SWITCH_CPU_PROFILE)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
generic_deferred_push(deferred_push_switch_gpu_profile, DISPLAYLIST_SWITCH_GPU_PROFILE)
|
||||
generic_deferred_push(deferred_push_switch_backlight_control, DISPLAYLIST_SWITCH_BACKLIGHT_CONTROL)
|
||||
generic_deferred_push(deferred_push_switch_cpu_profile, DISPLAYLIST_SWITCH_CPU_PROFILE)
|
||||
#endif
|
||||
|
||||
static int deferred_push_cursor_manager_list_deferred(
|
||||
@ -906,6 +909,8 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
|
||||
{
|
||||
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_switch_backlight_control);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
else if (strstr(label,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_SWITCH_CPU_PROFILE)))
|
||||
{
|
||||
|
@ -2524,25 +2524,34 @@ static int action_ok_deferred_list_stub(const char *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
static int action_ok_set_switch_cpu_profile(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
char* profile_name = SWITCH_CPU_PROFILES[entry_idx];
|
||||
|
||||
char command[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
snprintf(command, sizeof(command), "cpu-profile set %s", profile_name);
|
||||
|
||||
system(command);
|
||||
|
||||
snprintf(command, sizeof(command), "Current profile set to %s", profile_name);
|
||||
|
||||
#else
|
||||
config_get_ptr()->uints.libnx_overclock = entry_idx;
|
||||
|
||||
unsigned profile_clock = SWITCH_CPU_SPEEDS_VALUES[entry_idx];
|
||||
pcvSetClockRate(PcvModule_Cpu, (u32)profile_clock);
|
||||
snprintf(command, sizeof(command), "Current Clock set to %i", profile_clock);
|
||||
#endif
|
||||
|
||||
runloop_msg_queue_push(command, 1, 90, true);
|
||||
|
||||
return menu_cbs_exit();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
|
||||
static int action_ok_set_switch_gpu_profile(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
@ -5187,6 +5196,8 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE:
|
||||
case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL:
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
#endif
|
||||
BIND_ACTION_OK(cbs, action_ok_push_default);
|
||||
@ -5640,6 +5651,8 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
|
||||
case MENU_SET_SWITCH_BRIGHTNESS:
|
||||
BIND_ACTION_OK(cbs, action_ok_set_switch_backlight);
|
||||
break;
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case MENU_SET_SWITCH_CPU_PROFILE:
|
||||
BIND_ACTION_OK(cbs, action_ok_set_switch_cpu_profile);
|
||||
break;
|
||||
|
@ -485,9 +485,12 @@ default_sublabel_macro(action_bind_sublabel_show_wimp,
|
||||
#endif
|
||||
default_sublabel_macro(action_bind_sublabel_discord_allow, MENU_ENUM_SUBLABEL_DISCORD_ALLOW)
|
||||
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
default_sublabel_macro(action_bind_sublabel_switch_cpu_profile, MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
default_sublabel_macro(action_bind_sublabel_switch_gpu_profile, MENU_ENUM_SUBLABEL_SWITCH_GPU_PROFILE)
|
||||
default_sublabel_macro(action_bind_sublabel_switch_cpu_profile, MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE)
|
||||
default_sublabel_macro(action_bind_sublabel_switch_backlight_control, MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL)
|
||||
#endif
|
||||
|
||||
@ -2036,10 +2039,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_show_wimp);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_switch_cpu_profile);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_switch_gpu_profile);
|
||||
break;
|
||||
|
@ -210,9 +210,12 @@ default_title_copy_macro(action_get_title_cheevos_list, MENU_ENUM_LABE
|
||||
default_title_copy_macro(action_get_title_video_shader_parameters,MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS)
|
||||
default_title_copy_macro(action_get_title_video_shader_preset_parameters,MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS)
|
||||
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
default_title_macro(action_get_title_switch_cpu_profile, MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
default_title_macro(action_get_title_switch_gpu_profile, MENU_ENUM_LABEL_VALUE_SWITCH_GPU_PROFILE)
|
||||
default_title_macro(action_get_title_switch_cpu_profile, MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE)
|
||||
default_title_macro(action_get_title_switch_backlight_control, MENU_ENUM_LABEL_VALUE_SWITCH_BACKLIGHT_CONTROL)
|
||||
#endif
|
||||
|
||||
@ -879,13 +882,15 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_LIBRETRO_INFO_PATH:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_core_info_directory);
|
||||
break;
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_gpu_profile);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_backlight_control);
|
||||
break;
|
||||
@ -1176,13 +1181,15 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs,
|
||||
case MENU_LABEL_LIBRETRO_INFO_PATH:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_core_info_directory);
|
||||
break;
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_gpu_profile);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL:
|
||||
BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_backlight_control);
|
||||
break;
|
||||
|
@ -673,10 +673,12 @@ static int ozone_list_push(void *data, void *userdata,
|
||||
menu_displaylist_setting(&entry);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
entry.enum_idx = MENU_ENUM_LABEL_SWITCH_CPU_PROFILE;
|
||||
menu_displaylist_setting(&entry);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
entry.enum_idx = MENU_ENUM_LABEL_SWITCH_GPU_PROFILE;
|
||||
menu_displaylist_setting(&entry);
|
||||
|
||||
|
@ -211,7 +211,10 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone,
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_UI];
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE:
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_POWER];
|
||||
#endif
|
||||
case MENU_ENUM_LABEL_POWER_MANAGEMENT_SETTINGS:
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_POWER];
|
||||
|
@ -2450,7 +2450,10 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb,
|
||||
return xmb->textures.list[XMB_TEXTURE_UI];
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE:
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE:
|
||||
return xmb->textures.list[XMB_TEXTURE_POWER];
|
||||
#endif
|
||||
case MENU_ENUM_LABEL_POWER_MANAGEMENT_SETTINGS:
|
||||
return xmb->textures.list[XMB_TEXTURE_POWER];
|
||||
@ -5714,10 +5717,12 @@ static int xmb_list_push(void *data, void *userdata,
|
||||
menu_displaylist_setting(&entry);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
entry.enum_idx = MENU_ENUM_LABEL_SWITCH_CPU_PROFILE;
|
||||
menu_displaylist_setting(&entry);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
entry.enum_idx = MENU_ENUM_LABEL_SWITCH_GPU_PROFILE;
|
||||
menu_displaylist_setting(&entry);
|
||||
|
||||
|
@ -51,6 +51,11 @@
|
||||
#include "../../lakka.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
#include <switch.h>
|
||||
#include "../../switch_performance_profiles.h"
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || (defined(BSD) && !defined(__MACH__))
|
||||
#include "../frontend/drivers/platform_unix.h"
|
||||
#endif
|
||||
@ -4265,7 +4270,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
|
||||
switch (type)
|
||||
{
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
case DISPLAYLIST_SWITCH_CPU_PROFILE:
|
||||
{
|
||||
unsigned i;
|
||||
@ -4274,17 +4279,22 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
FILE *profile = NULL;
|
||||
const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES)/sizeof(SWITCH_CPU_PROFILES[1]);
|
||||
|
||||
runloop_msg_queue_push("Warning : extented overclocking can damage the Switch", 1, 90, true);
|
||||
runloop_msg_queue_push("Warning : extended overclocking can damage the Switch", 1, 90, true);
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
|
||||
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
profile = popen("cpu-profile get", "r");
|
||||
fgets(current_profile, PATH_MAX_LENGTH, profile);
|
||||
pclose(profile);
|
||||
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
|
||||
|
||||
snprintf(text, sizeof(text),
|
||||
"Current profile : %s", current_profile);
|
||||
|
||||
snprintf(text, sizeof(text), "Current profile : %s", current_profile);
|
||||
#else
|
||||
u32 currentClock = 0;
|
||||
pcvGetClockRate(PcvModule_Cpu, ¤tClock);
|
||||
snprintf(text, sizeof(text), "Current Clock : %i", currentClock);
|
||||
#endif
|
||||
menu_entries_append_enum(info->list,
|
||||
text,
|
||||
"",
|
||||
@ -4313,6 +4323,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
|
||||
break;
|
||||
}
|
||||
#if defined(HAVE_LAKKA_SWITCH)
|
||||
case DISPLAYLIST_SWITCH_GPU_PROFILE:
|
||||
{
|
||||
unsigned i;
|
||||
@ -4330,7 +4341,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
|
||||
|
||||
snprintf(text, sizeof(text), "Current profile : %s", current_profile);
|
||||
|
||||
|
||||
menu_entries_append_enum(info->list,
|
||||
text,
|
||||
"",
|
||||
@ -4383,7 +4394,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#endif // HAVE_LAKKA_SWITCH
|
||||
#endif // HAVE_LAKKA_SWITCH || HAVE_LIBNX
|
||||
case DISPLAYLIST_MUSIC_LIST:
|
||||
{
|
||||
char combined_path[PATH_MAX_LENGTH];
|
||||
|
@ -183,6 +183,8 @@ enum menu_displaylist_ctl_state
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
DISPLAYLIST_SWITCH_GPU_PROFILE,
|
||||
DISPLAYLIST_SWITCH_BACKLIGHT_CONTROL,
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
DISPLAYLIST_SWITCH_CPU_PROFILE,
|
||||
#endif
|
||||
DISPLAYLIST_PENDING_CLEAR
|
||||
|
@ -245,6 +245,8 @@ enum menu_settings_type
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
MENU_SET_SWITCH_GPU_PROFILE,
|
||||
MENU_SET_SWITCH_BRIGHTNESS,
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MENU_SET_SWITCH_CPU_PROFILE,
|
||||
#endif
|
||||
|
||||
|
@ -3750,8 +3750,7 @@ static bool setting_append_list(
|
||||
menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_QUIT);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LAKKA)
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
CONFIG_ACTION(
|
||||
list, list_info,
|
||||
MENU_ENUM_LABEL_SWITCH_CPU_PROFILE,
|
||||
@ -3759,7 +3758,10 @@ static bool setting_append_list(
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LAKKA)
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
CONFIG_ACTION(
|
||||
list, list_info,
|
||||
MENU_ENUM_LABEL_SWITCH_GPU_PROFILE,
|
||||
|
@ -2172,7 +2172,8 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
MENU_ENUM_LABEL_VALUE_SWITCH_BACKLIGHT_CONTROL,
|
||||
MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL,
|
||||
|
||||
#endif
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
MENU_ENUM_LABEL_SWITCH_CPU_PROFILE,
|
||||
MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE,
|
||||
MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE,
|
||||
|
125
switch_performance_profiles.h
Normal file
125
switch_performance_profiles.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2018-2018 - Natinusala
|
||||
* Copyright (C) 2018-2018 - M4xw
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SWITCH_PERFORMANCE_PROFILES_H
|
||||
#define __SWITCH_PERFORMANCE_PROFILES_H
|
||||
|
||||
#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX)
|
||||
#ifdef HAVE_LAKKA_SWITCH
|
||||
static char *SWITCH_GPU_PROFILES[] = {
|
||||
"docked-overclock-3",
|
||||
"docked-overclock-2",
|
||||
"docked-overclock-1",
|
||||
"docked",
|
||||
"non-docked-overclock-5",
|
||||
"non-docked-overclock-4",
|
||||
"non-docked-overclock-3",
|
||||
"non-docked-overclock-2",
|
||||
"non-docked-overclock-1",
|
||||
"non-docked",
|
||||
"non-docked-underclock-1",
|
||||
"non-docked-underclock-2",
|
||||
"non-docked-underclock-3",
|
||||
};
|
||||
|
||||
static char *SWITCH_GPU_SPEEDS[] = {
|
||||
"998 Mhz",
|
||||
"921 Mhz",
|
||||
"844 Mhz",
|
||||
"768 Mhz",
|
||||
"691 Mhz",
|
||||
"614 Mhz",
|
||||
"537 Mhz",
|
||||
"460 Mhz",
|
||||
"384 Mhz",
|
||||
"307 Mhz",
|
||||
"230 Mhz",
|
||||
"153 Mhz",
|
||||
"76 Mhz"};
|
||||
|
||||
static int SWITCH_BRIGHTNESS[] = {
|
||||
10,
|
||||
20,
|
||||
30,
|
||||
40,
|
||||
50,
|
||||
60,
|
||||
70,
|
||||
80,
|
||||
90,
|
||||
100};
|
||||
#endif
|
||||
|
||||
static char *SWITCH_CPU_PROFILES[] = {
|
||||
#ifndef HAVE_LIBNX
|
||||
"overclock-4",
|
||||
"overclock-3",
|
||||
"overclock-2",
|
||||
"overclock-1",
|
||||
"default",
|
||||
#else
|
||||
"Maximum Performance",
|
||||
"High Performance",
|
||||
"Boost Performance",
|
||||
"Stock Performance",
|
||||
"Powersaving Mode 1",
|
||||
"Powersaving Mode 2",
|
||||
"Powersaving Mode 3",
|
||||
#endif
|
||||
};
|
||||
|
||||
#define SWITCH_DEFAULT_CPU_PROFILE 3 /* Stock Performance */
|
||||
#define LIBNX_MAX_CPU_PROFILE 0 /* Max Performance */
|
||||
|
||||
static char *SWITCH_CPU_SPEEDS[] = {
|
||||
#ifndef HAVE_LIBNX
|
||||
"1912 MHz",
|
||||
"1734 MHz",
|
||||
"1530 MHz",
|
||||
"1224 MHz",
|
||||
"1020 MHz"
|
||||
#else
|
||||
"1785 MHz",
|
||||
"1581 MHz",
|
||||
"1224 MHz",
|
||||
"1020 MHz",
|
||||
"918 MHz",
|
||||
"816 MHz",
|
||||
"714 MHz"
|
||||
#endif
|
||||
};
|
||||
|
||||
static unsigned SWITCH_CPU_SPEEDS_VALUES[] = {
|
||||
#ifndef HAVE_LIBNX
|
||||
1912000000,
|
||||
1734000000,
|
||||
1530000000,
|
||||
1224000000,
|
||||
1020000000
|
||||
#else
|
||||
1785000000,
|
||||
1581000000,
|
||||
1224000000,
|
||||
1020000000,
|
||||
918000000,
|
||||
816000000,
|
||||
714000000
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user