1 | #ifndef SETTINGS_OVERCLOCKING_H |
---|
2 | #define SETTINGS_OVERCLOCKING_H |
---|
3 | |
---|
4 | void read_cpufreq(struct skin* label) |
---|
5 | { |
---|
6 | if(isfile("/proc/cpu_frequ/pll0_ndiv_mdiv") == 0) |
---|
7 | { |
---|
8 | changetext(label, NULL); |
---|
9 | return; |
---|
10 | } |
---|
11 | |
---|
12 | char* tmpstr = NULL, *tmpstr1 = NULL, **tmpstr2 = NULL; |
---|
13 | int i = 0; |
---|
14 | |
---|
15 | tmpstr1 = ostrcat(tmpstr1, command("cat /proc/cpu_frequ/pll0_ndiv_mdiv"), 1, 0); |
---|
16 | if(tmpstr1 == NULL) |
---|
17 | { |
---|
18 | changetext(label, NULL); |
---|
19 | return; |
---|
20 | } |
---|
21 | tmpstr2 = str_split(tmpstr1, "\n"); |
---|
22 | |
---|
23 | if(tmpstr2 != NULL) |
---|
24 | { |
---|
25 | for(i = 0; tmpstr2[i] != NULL; i++) |
---|
26 | { |
---|
27 | if(ostrstr(tmpstr2[i], "CKGA_") != 0) |
---|
28 | { |
---|
29 | free(tmpstr2[i]); tmpstr2[i] = NULL; |
---|
30 | } |
---|
31 | else if(ostrstr(tmpstr2[i], "SYSACLKOUT") != 0) |
---|
32 | { |
---|
33 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
34 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
35 | } |
---|
36 | else if(ostrstr(tmpstr2[i], "BOGOMIPS") != 0) |
---|
37 | { |
---|
38 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
39 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
40 | } |
---|
41 | else if(ostrstr(tmpstr2[i], "PLL0") != 0) |
---|
42 | { |
---|
43 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
44 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
45 | } |
---|
46 | else if(ostrstr(tmpstr2[i], "SH4") != 0){ |
---|
47 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
48 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
49 | } |
---|
50 | else if(ostrstr(tmpstr2[i], "MODULE") != 0) |
---|
51 | { |
---|
52 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
53 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
54 | } |
---|
55 | else if(ostrstr(tmpstr2[i], "SLIM") != 0) |
---|
56 | { |
---|
57 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
58 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
59 | } |
---|
60 | else if(ostrstr(tmpstr2[i], "PLL1") != 0) |
---|
61 | { |
---|
62 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
63 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
64 | } |
---|
65 | else if(ostrstr(tmpstr2[i], "COMMS") != 0) |
---|
66 | { |
---|
67 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
68 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
69 | } |
---|
70 | else if(ostrstr(tmpstr2[i], "TMU0") != 0) |
---|
71 | { |
---|
72 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
73 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
74 | } |
---|
75 | else if(ostrstr(tmpstr2[i], "TMU0") != 0) |
---|
76 | { |
---|
77 | tmpstr = ostrcat(tmpstr, tmpstr2[i], 1, 1); |
---|
78 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
79 | } |
---|
80 | else |
---|
81 | { |
---|
82 | free(tmpstr2[i]); tmpstr2[i] = NULL; |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | changetext(label, _(tmpstr)); |
---|
87 | } |
---|
88 | |
---|
89 | void set_freq(char* inifreq, char* oldfreq, char* newfreq) |
---|
90 | { |
---|
91 | if(isfile("/proc/cpu_frequ/pll0_ndiv_mdiv") == 0) |
---|
92 | { |
---|
93 | debug(10, "file not found %s", "/proc/cpu_frequ/pll0_ndiv_mdiv"); |
---|
94 | return; |
---|
95 | } |
---|
96 | |
---|
97 | debug(10, "inifreq=%s oldfreq=%s => newfreq=%s", inifreq, oldfreq, newfreq); |
---|
98 | |
---|
99 | if(ostrcmp(newfreq, inifreq) == 0 && ostrcmp(newfreq, oldfreq) == 0) |
---|
100 | { |
---|
101 | debug(10, "Nothing to change in FREQ"); |
---|
102 | return; |
---|
103 | } |
---|
104 | |
---|
105 | char* tmpstr = NULL; |
---|
106 | |
---|
107 | tmpstr = ostrcat(tmpstr, "echo \"", 1, 0); |
---|
108 | tmpstr = ostrcat(tmpstr, newfreq, 1, 0); |
---|
109 | tmpstr = ostrcat(tmpstr, "\" > /proc/cpu_frequ/pll0_ndiv_mdiv", 1, 0); |
---|
110 | |
---|
111 | debug(10, "Set FREQ to %s", newfreq); |
---|
112 | system(tmpstr); |
---|
113 | |
---|
114 | if(oldfreq != NULL && newfreq != NULL){ |
---|
115 | strcpy(oldfreq, newfreq); |
---|
116 | } |
---|
117 | return; |
---|
118 | } |
---|
119 | |
---|
120 | void set_fdma(char* inifdma, char* oldfdma, char* newfdma) |
---|
121 | { |
---|
122 | if(checkbox("UFS912") || checkbox("ATEMIO520") || checkbox("ATEMIO530") || checkbox("SPARK") || checkbox("ATEMIO510") || checkbox("ATEMIO7600") || checkbox("WHITEBOX")) |
---|
123 | return; |
---|
124 | |
---|
125 | if(isfile("/proc/cpu_frequ/pll1_fdma_bypass") == 0) |
---|
126 | { |
---|
127 | debug(10, "file not found %s", "/proc/cpu_frequ/pll1_fdma_bypass"); |
---|
128 | return; |
---|
129 | } |
---|
130 | |
---|
131 | if(ostrcmp(newfdma, inifdma) == 0 && ostrcmp(newfdma, oldfdma) == 0) |
---|
132 | { |
---|
133 | debug(10, "Nothing to change in FDMA"); |
---|
134 | return; |
---|
135 | } |
---|
136 | |
---|
137 | char* tmpstr = NULL; |
---|
138 | |
---|
139 | tmpstr = ostrcat(tmpstr, "echo \"", 1, 0); |
---|
140 | tmpstr = ostrcat(tmpstr, newfdma, 1, 0); |
---|
141 | tmpstr = ostrcat(tmpstr, "\" > /proc/cpu_frequ/pll1_fdma_bypass", 1, 0); |
---|
142 | |
---|
143 | debug(10, "Set FDMA to %s", newfdma); |
---|
144 | system(tmpstr); |
---|
145 | |
---|
146 | if(oldfdma != NULL && newfdma != NULL) |
---|
147 | strcpy(oldfdma, newfdma); |
---|
148 | |
---|
149 | return; |
---|
150 | } |
---|
151 | |
---|
152 | char* getlistvalue(struct skin* mylist, char* name) |
---|
153 | { |
---|
154 | struct skin* node = NULL; |
---|
155 | char* tmpstr = NULL; |
---|
156 | int tmpaktpage = mylist->aktpage; |
---|
157 | int tmpaktline = mylist->aktline; |
---|
158 | |
---|
159 | mylist->aktpage = -1; |
---|
160 | mylist->aktline = 1; |
---|
161 | node = mylist->next; |
---|
162 | |
---|
163 | while(node != NULL) |
---|
164 | { |
---|
165 | if(ostrcmp(name, node->name) == 0) |
---|
166 | { |
---|
167 | tmpstr = ostrcat(tmpstr, node->ret, 1, 0); |
---|
168 | break; |
---|
169 | } |
---|
170 | node = node->next; |
---|
171 | } |
---|
172 | |
---|
173 | mylist->aktpage = tmpaktpage; |
---|
174 | mylist->aktline = tmpaktline; |
---|
175 | return tmpstr; |
---|
176 | } |
---|
177 | |
---|
178 | void screensettings_overclocking() |
---|
179 | { |
---|
180 | int rcret = 0; |
---|
181 | struct skin* panel_overclock = getscreen("settings_overclocking"); |
---|
182 | struct skin* listbox = getscreennode(panel_overclock, "listbox"); |
---|
183 | struct skin* label1 = getscreennode(panel_overclock, "label1"); |
---|
184 | struct skin* node = NULL; |
---|
185 | struct skin* tmp = NULL; |
---|
186 | |
---|
187 | char* FreqSelvalue = NULL, *FreqSeltext = NULL; |
---|
188 | char* standbyFreqSelvalue = NULL, *standbyFreqSeltext = NULL; |
---|
189 | char* inifreq = NULL, *oldfreq = NULL; |
---|
190 | char* inifdma = NULL, *oldfdma = NULL; |
---|
191 | |
---|
192 | addscreenrc(panel_overclock, listbox); |
---|
193 | |
---|
194 | if(checkbox("UFS912") || checkbox("ATEMIO520") || checkbox("ATEMIO530") || checkbox("SPARK") || checkbox("ATEMIO510") || checkbox("ATEMIO7600") || checkbox("WHITEBOX")) |
---|
195 | { |
---|
196 | FreqSelvalue = "3841\n12803\n5121\n16643\n17923"; |
---|
197 | FreqSeltext = "450 (default)\n500\n600\n650\n700"; |
---|
198 | standbyFreqSelvalue = "3841\n2561\n5123\n2563"; |
---|
199 | standbyFreqSeltext = "450 (default)\n300\n200\n100"; |
---|
200 | } |
---|
201 | else |
---|
202 | { |
---|
203 | FreqSelvalue = "15110\n25609\n9475\n31241\n22790"; |
---|
204 | FreqSeltext = "266 (default)\n300\n333\n366\n400"; |
---|
205 | standbyFreqSelvalue = "15110\n51227\n42523\n34075"; |
---|
206 | standbyFreqSeltext = "266 (default)\n200\n166\n133"; |
---|
207 | } |
---|
208 | |
---|
209 | node = addlistbox(panel_overclock, listbox, node, 1); |
---|
210 | if(node != NULL) |
---|
211 | { |
---|
212 | node->type = CHOICEBOX; |
---|
213 | changetext(node, _("Only Boot Overclock")); changename(node, "only_boot_overclock"); |
---|
214 | addchoicebox(node, "0", _("no")); addchoicebox(node, "1", _("yes")); |
---|
215 | setchoiceboxselection(node, getownconfig(node->name)); |
---|
216 | } |
---|
217 | |
---|
218 | node = addlistbox(panel_overclock, listbox, node, 1); |
---|
219 | if(node != NULL) |
---|
220 | { |
---|
221 | node->type = CHOICEBOX; |
---|
222 | changetext(node, _("CPU frequency")); changename(node, "pll0_ndiv_mdiv"); |
---|
223 | addchoicebox(node, FreqSelvalue, _(FreqSeltext)); |
---|
224 | setchoiceboxselection(node, getownconfig(node->name)); |
---|
225 | } |
---|
226 | |
---|
227 | if(checkbox("UFS912") == 0 && checkbox("ATEMIO520") == 0 && checkbox("ATEMIO530") == 0 && checkbox("SPARK") == 0 && checkbox("ATEMIO510") == 0 && checkbox("ATEMIO7600") == 0 && checkbox("WHITEBOX") == 0) |
---|
228 | { |
---|
229 | node = addlistbox(panel_overclock, listbox, node, 1); |
---|
230 | if(node != NULL) |
---|
231 | { |
---|
232 | node->type = CHOICEBOX; |
---|
233 | changetext(node, _("FDMA bypass")); changename(node, "pll1_fdma_bypass"); |
---|
234 | addchoicebox(node, "0", _("no")); addchoicebox(node, "1", _("yes")); |
---|
235 | setchoiceboxselection(node, getownconfig(node->name)); |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | node = addlistbox(panel_overclock, listbox, node, 1); |
---|
240 | if(node != NULL) |
---|
241 | { |
---|
242 | node->type = CHOICEBOX; |
---|
243 | changetext(node, _("Reduce Standby frequency")); changename(node, "standby_overclock"); |
---|
244 | addchoicebox(node, "0", _("no")); addchoicebox(node, "1", _("yes")); |
---|
245 | setchoiceboxselection(node, getownconfig(node->name)); |
---|
246 | |
---|
247 | if(ostrcmp(getownconfig(node->name), "1") == 0) |
---|
248 | { |
---|
249 | node = addlistbox(panel_overclock, listbox, node, 1); |
---|
250 | if(node != NULL) |
---|
251 | { |
---|
252 | node->type = CHOICEBOX; |
---|
253 | changetext(node, _("Standby frequency")); changename(node, "standby_freq"); |
---|
254 | addchoicebox(node, standbyFreqSelvalue, _(standbyFreqSeltext)); |
---|
255 | setchoiceboxselection(node, getownconfig(node->name)); |
---|
256 | } |
---|
257 | } |
---|
258 | else |
---|
259 | { |
---|
260 | node = addlistbox(panel_overclock, listbox, node, 1); |
---|
261 | if(node != NULL) |
---|
262 | { |
---|
263 | node->type = CHOICEBOX; |
---|
264 | changetext(node, NULL); changename(node, "standby_freq"); |
---|
265 | } |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | if(checkbox("UFS912") == 0 && checkbox("ATEMIO520") == 0 && checkbox("ATEMIO530") == 0 && checkbox("SPARK") == 0 && checkbox("ATEMIO510") == 0 && checkbox("ATEMIO7600") == 0 && checkbox("WHITEBOX") == 0) |
---|
270 | { |
---|
271 | node = addlistbox(panel_overclock, listbox, node, 1); |
---|
272 | if(node != NULL) |
---|
273 | { |
---|
274 | node->type = CHOICEBOX; |
---|
275 | changetext(node, _("Use Teletxt Workaround")); changename(node, "tuxtxt_cpufrequ_workaround"); |
---|
276 | addchoicebox(node, "0", _("off")); addchoicebox(node, "1", _("frequency")); addchoicebox(node, "1", _("videmode")); |
---|
277 | setchoiceboxselection(node, getownconfig(node->name)); |
---|
278 | } |
---|
279 | } |
---|
280 | |
---|
281 | read_cpufreq(label1); |
---|
282 | drawscreen(panel_overclock, 0, 0); |
---|
283 | |
---|
284 | inifreq = getlistvalue(listbox,"pll0_ndiv_mdiv"); |
---|
285 | oldfreq = getlistvalue(listbox,"pll0_ndiv_mdiv"); |
---|
286 | inifdma = getlistvalue(listbox,"pll1_fdma_bypass"); |
---|
287 | oldfdma = getlistvalue(listbox,"pll1_fdma_bypass"); |
---|
288 | |
---|
289 | tmp = listbox->select; |
---|
290 | |
---|
291 | while(1) |
---|
292 | { |
---|
293 | addscreenrc(panel_overclock, tmp); |
---|
294 | rcret = waitrc(panel_overclock, 0, 0); |
---|
295 | tmp = listbox->select; |
---|
296 | |
---|
297 | if(rcret == getrcconfigint("rcexit", NULL)) |
---|
298 | { |
---|
299 | set_freq(inifreq, oldfreq, inifreq); // set freq back to initial value if freq <> inifreq |
---|
300 | set_fdma(inifdma, oldfdma, inifdma); |
---|
301 | break; |
---|
302 | } |
---|
303 | |
---|
304 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
305 | { |
---|
306 | set_freq(oldfreq, oldfreq, getownconfig("pll0_ndiv_mdiv")); |
---|
307 | set_fdma(oldfdma, oldfdma, getownconfig("pll1_fdma_bypass")); |
---|
308 | read_cpufreq(label1); |
---|
309 | drawscreen(panel_overclock, 0, 0); |
---|
310 | } |
---|
311 | |
---|
312 | if(listbox->select != NULL) |
---|
313 | { |
---|
314 | addownconfigscreentmp(listbox->select->name, listbox->select); |
---|
315 | if(ostrcmp(listbox->select->name, "standby_overclock") == 0) |
---|
316 | { |
---|
317 | listbox->select = listbox->select->next; |
---|
318 | |
---|
319 | if(ostrcmp(getownconfig("standby_overclock"), "1") == 0) |
---|
320 | { |
---|
321 | changetext(listbox->select, _("Standby frequency")); |
---|
322 | addchoicebox(listbox->select, standbyFreqSelvalue, _(standbyFreqSeltext)); |
---|
323 | setchoiceboxselection(listbox->select, getownconfig("standby_freq")); |
---|
324 | } |
---|
325 | else |
---|
326 | { |
---|
327 | changetext(listbox->select, NULL); |
---|
328 | changeinput(listbox->select, NULL); |
---|
329 | } |
---|
330 | drawscreen(panel_overclock, 0, 0); |
---|
331 | } |
---|
332 | } |
---|
333 | |
---|
334 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
335 | { |
---|
336 | set_freq(oldfreq, oldfreq, getownconfig("pll0_ndiv_mdiv")); |
---|
337 | set_fdma(oldfdma, oldfdma, getownconfig("pll1_fdma_bypass")); |
---|
338 | writeownconfigtmp(); |
---|
339 | break; |
---|
340 | } |
---|
341 | } |
---|
342 | |
---|
343 | FreqSelvalue = NULL; FreqSeltext = NULL; standbyFreqSelvalue = NULL; standbyFreqSeltext = NULL; tmp = NULL; |
---|
344 | inifreq = NULL; oldfreq = NULL; inifdma = NULL; oldfdma = NULL; |
---|
345 | delownconfigtmpall(); |
---|
346 | delmarkedscreennodes(panel_overclock, 1); |
---|
347 | delownerrc(panel_overclock); |
---|
348 | clearscreen(panel_overclock); |
---|
349 | } |
---|
350 | |
---|
351 | #endif |
---|