Skip to content

Commit 1ad4374

Browse files
Switch: Fix Clock speed menus on mariko. (#1822)
1 parent 35384ad commit 1ad4374

5 files changed

Lines changed: 391 additions & 49 deletions

File tree

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
From f18ed2c4f41d06f1992574e093e7c347f6f081dc Mon Sep 17 00:00:00 2001
2+
From: Ronald Brown <[email protected]>
3+
Date: Thu, 12 Jan 2023 20:49:58 -0800
4+
Subject: [PATCH] Lakka:Switch: Add Support for mariko clocks
5+
6+
---
7+
menu/cbs/menu_cbs_ok.c | 26 +++++++++++++--
8+
menu/menu_displaylist.c | 55 +++++++++++++++++++++++++++---
9+
switch_performance_profiles.h | 63 +++++++++++++++++++++++++++++++++++
10+
3 files changed, 136 insertions(+), 8 deletions(-)
11+
12+
diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c
13+
index 0e3d97b821..83875d6afa 100644
14+
--- a/menu/cbs/menu_cbs_ok.c
15+
+++ b/menu/cbs/menu_cbs_ok.c
16+
@@ -3857,7 +3857,18 @@ static int action_ok_set_switch_cpu_profile(const char *path,
17+
{
18+
char command[PATH_MAX_LENGTH] = {0};
19+
#ifdef HAVE_LAKKA_SWITCH
20+
- char* profile_name = SWITCH_CPU_PROFILES[entry_idx];
21+
+ char* profile_name;
22+
+ char soc[2];
23+
+ FILE *board = NULL;
24+
+ board = popen("cpu-profile board-info", "r");
25+
+ fgets(soc, 2, board);
26+
+ pclose(board);
27+
+
28+
+ if ( soc[0] == 'E' ) {
29+
+ profile_name=SWITCH_CPU_PROFILES[entry_idx];
30+
+ } else if (soc[0] == 'M' ) {
31+
+ profile_name=SWITCH_CPU_PROFILES_MARIKO[entry_idx];
32+
+ }
33+
34+
snprintf(command, sizeof(command), "cpu-profile set '%s'", profile_name);
35+
36+
@@ -3895,8 +3906,17 @@ static int action_ok_set_switch_gpu_profile(const char *path,
37+
const char *label, unsigned type, size_t idx, size_t entry_idx)
38+
{
39+
char command[PATH_MAX_LENGTH];
40+
- char *profile_name = SWITCH_GPU_PROFILES[entry_idx];
41+
-
42+
+ char soc[2];
43+
+ FILE *board = NULL;
44+
+ board = popen("gpu-profile board-info", "r");
45+
+ fgets(soc, 2, board);
46+
+ pclose(board);
47+
+ char *profile_name;
48+
+ if (soc[0] == 'M') {
49+
+ profile_name = SWITCH_GPU_PROFILES_MARIKO[entry_idx];
50+
+ } else if (soc[0] == 'E') {
51+
+ profile_name = SWITCH_GPU_PROFILES[entry_idx];
52+
+ }
53+
command[0] = '\0';
54+
55+
snprintf(command, sizeof(command),
56+
diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c
57+
index e5d9b1acb7..940a60c3c0 100644
58+
--- a/menu/menu_displaylist.c
59+
+++ b/menu/menu_displaylist.c
60+
@@ -11704,8 +11704,20 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
61+
#ifdef HAVE_LAKKA_SWITCH
62+
char current_profile[PATH_MAX_LENGTH];
63+
FILE *profile = NULL;
64+
-#endif
65+
+ size_t profiles_count = 0;
66+
+ char soc[2];
67+
+ FILE *board = NULL;
68+
+ board = popen("cpu-profile board-info", "r");
69+
+ fgets(soc, 2, board);
70+
+ pclose(board);
71+
+ if ( soc[0] == 'E') {
72+
+ profiles_count = sizeof(SWITCH_CPU_PROFILES)/sizeof(SWITCH_CPU_PROFILES[1]);
73+
+ } else if (soc[0] == 'M') {
74+
+ profiles_count = sizeof(SWITCH_CPU_PROFILES_MARIKO)/sizeof(SWITCH_CPU_PROFILES_MARIKO[1]);
75+
+ }
76+
+#else
77+
const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES)/sizeof(SWITCH_CPU_PROFILES[1]);
78+
+#endif
79+
80+
runloop_msg_queue_push("Warning : extended overclocking can damage the Switch", 1, 90, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
81+
82+
@@ -11737,12 +11749,24 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
83+
0,
84+
MENU_INFO_MESSAGE, 0, 0, NULL))
85+
count++;
86+
-
87+
for (i = 0; i < profiles_count; i++)
88+
{
89+
char title[PATH_MAX_LENGTH];
90+
+#ifdef HAVE_LAKKA_SWITCH
91+
+ char* profile;
92+
+ char* speed;
93+
+ if (soc[0] == 'E') {
94+
+ profile = SWITCH_CPU_PROFILES[i];
95+
+ speed = SWITCH_CPU_SPEEDS[i];
96+
+ } else if (soc[0] == 'M') {
97+
+ profile = SWITCH_CPU_PROFILES_MARIKO[i];
98+
+ speed = SWITCH_CPU_SPEEDS_MARIKO[i];
99+
+
100+
+ }
101+
+#else
102+
char* profile = SWITCH_CPU_PROFILES[i];
103+
char* speed = SWITCH_CPU_SPEEDS[i];
104+
+#endif
105+
title[0] = '\0';
106+
107+
snprintf(title, sizeof(title), "%s (%s)", profile, speed);
108+
@@ -11766,8 +11790,20 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
109+
unsigned i;
110+
char text[PATH_MAX_LENGTH];
111+
char current_profile[PATH_MAX_LENGTH];
112+
+ size_t profiles_count = 0;
113+
FILE *profile = NULL;
114+
- const size_t profiles_count = sizeof(SWITCH_GPU_PROFILES)/sizeof(SWITCH_GPU_PROFILES[1]);
115+
+
116+
+ char soc[2];
117+
+ FILE *board = NULL;
118+
+ board = popen("gpu-profile board-info", "r");
119+
+ fgets(soc, 2, board);
120+
+ pclose(board);
121+
+
122+
+ if (soc[0] == 'E') {
123+
+ profiles_count = sizeof(SWITCH_GPU_PROFILES)/sizeof(SWITCH_GPU_PROFILES[1]);
124+
+ } else if (soc[0] == 'M') {
125+
+ profiles_count = sizeof(SWITCH_GPU_PROFILES_MARIKO)/sizeof(SWITCH_GPU_PROFILES_MARIKO[1]);
126+
+ }
127+
128+
runloop_msg_queue_push("Warning : extended overclocking can damage the Switch", 1, 90, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
129+
130+
@@ -11787,8 +11823,17 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
131+
for (i = 0; i < profiles_count; i++)
132+
{
133+
char title[PATH_MAX_LENGTH];
134+
- char* profile = SWITCH_GPU_PROFILES[i];
135+
- char* speed = SWITCH_GPU_SPEEDS[i];
136+
+ char* profile;
137+
+ char* speed;
138+
+ if (soc[0] == 'E') {
139+
+ profile = SWITCH_GPU_PROFILES[i];
140+
+ speed = SWITCH_GPU_SPEEDS[i];
141+
+ } else if (soc[0] == 'M') {
142+
+ profile = SWITCH_GPU_PROFILES_MARIKO[i];
143+
+ speed = SWITCH_GPU_SPEEDS_MARIKO[i];
144+
+
145+
+ }
146+
+
147+
148+
snprintf(title, sizeof(title), "%s (%s)", profile, speed);
149+
150+
diff --git a/switch_performance_profiles.h b/switch_performance_profiles.h
151+
index 5d07ba6ed5..ab92b0e114 100644
152+
--- a/switch_performance_profiles.h
153+
+++ b/switch_performance_profiles.h
154+
@@ -48,6 +48,69 @@ static char *SWITCH_GPU_SPEEDS[] = {
155+
"153 Mhz",
156+
"76 Mhz"
157+
};
158+
+
159+
+static char *SWITCH_GPU_PROFILES_MARIKO[] = {
160+
+ "Docked Stock +3",
161+
+ "Docked Stock +2",
162+
+ "Docked Stock +1",
163+
+ "Docked Stock Mode",
164+
+ "Handheld Boost +3",
165+
+ "Handheld Boost +2",
166+
+ "Handheld Boost +1",
167+
+ "Handheld Boost Mode",
168+
+ "Handheld Stock +1",
169+
+ "Handheld Stock Mode",
170+
+ "Powersaving +2",
171+
+ "Powersaving +1",
172+
+ "Powersaving Mode",
173+
+};
174+
+
175+
+static char *SWITCH_GPU_SPEEDS_MARIKO[] = {
176+
+ "998 Mhz",
177+
+ "921 Mhz",
178+
+ "844 Mhz",
179+
+ "768 Mhz",
180+
+ "691 Mhz",
181+
+ "614 Mhz",
182+
+ "537 Mhz",
183+
+ "460 Mhz",
184+
+ "384 Mhz",
185+
+ "307 Mhz",
186+
+ "230 Mhz",
187+
+ "153 Mhz",
188+
+ "76 Mhz"
189+
+};
190+
+
191+
+static char *SWITCH_CPU_PROFILES_MARIKO[] = {
192+
+ "Max Overdrive +3",
193+
+ "Max Overdrive +2",
194+
+ "Max Overdrive +1",
195+
+ "Maximum Performance",
196+
+ "Boost Performance 4",
197+
+ "Boost Performance 3",
198+
+ "Boost Performance 2",
199+
+ "Boost Performance 1",
200+
+ "Stock Performance",
201+
+ "Powersaving Mode 1",
202+
+ "Powersaving Mode 2",
203+
+ "Powersaving Mode 3"
204+
+};
205+
+
206+
+static char *SWITCH_CPU_SPEEDS_MARIKO[] = {
207+
+ " **UNSTABLE** 2295 MHz",
208+
+ " **UNSTABLE** 2193 MHz",
209+
+ " **UNSTABLE** 2091 MHz",
210+
+ "1963 MHz",
211+
+ "1887 MHz",
212+
+ "1785 MHz",
213+
+ "1581 MHz",
214+
+ "1224 MHz",
215+
+ "1020 MHz",
216+
+ "918 MHz",
217+
+ "816 MHz",
218+
+ "714 MHz"
219+
+};
220+
+
221+
#endif
222+
223+
static char *SWITCH_CPU_PROFILES[] = {
224+
--
225+
2.35.1
226+

projects/L4T/devices/Switch/packages/switch-cpu-profile/package.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
PKG_NAME="switch-cpu-profile"
2-
PKG_VERSION="1.1"
2+
PKG_VERSION="2.0"
33
PKG_DEPENDS_TARGET="Python3"
44
PKG_TOOLCHAIN="manual"
55

66
makeinstall_target() {
77
mkdir -p ${INSTALL}/usr/bin
8-
#cp -v ${PKG_DIR}/scripts/cpu-profile ${INSTALL}/usr/bin
9-
touch ${INSTALL}/usr/bin/cpu-profile
8+
cp -v ${PKG_DIR}/scripts/cpu-profile ${INSTALL}/usr/bin
109
chmod +x ${INSTALL}/usr/bin/cpu-profile
1110
}
1211

0 commit comments

Comments
 (0)