source: titan/plugins/panel/panel_settings_overclocking.h @ 11416

Last change on this file since 11416 was 11416, checked in by nit, 12 years ago

[titan] first step remove aaf text

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