2 /* commandline.c for GP2X Version 2.0
3 Copyright (C) 2006 god_at_hell
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "gp2xminilib.h"
29 void fallback(int argc, char *argv[])
31 //beginning commandline-utilizing
34 if (atoi(argv[1]) == 0)
36 if(atoi(argv[2]) > 36){gp2x_deinit();exit(1);}
37 if(atoi(argv[2]) < -20){gp2x_deinit();exit(1);}
38 set_add_FLCDCLK(atoi(argv[2]));
42 if(atoi(argv[2]) > 10){gp2x_deinit();exit(1);}
43 if(atoi(argv[2]) < -5){gp2x_deinit();exit(1);}
44 set_add_ULCDCLK(atoi(argv[2]));
50 if(atoi(argv[3]) > 320){gp2x_deinit();exit(1);}
51 if(atoi(argv[3]) < 33){gp2x_deinit();exit(1);}
52 if (atoi(argv[1]) == 0)
54 if(atoi(argv[2]) > 36){gp2x_deinit();exit(1);}
55 if(atoi(argv[2]) < -20){gp2x_deinit();exit(1);}
56 set_add_FLCDCLK(atoi(argv[2]));
60 if(atoi(argv[2]) > 10){gp2x_deinit();exit(1);}
61 if(atoi(argv[2]) < -5){gp2x_deinit();exit(1);}
62 set_add_ULCDCLK(atoi(argv[2]));
64 set_FCLK(atoi(argv[3]));
69 if(atoi(argv[3]) > 320){gp2x_deinit();exit(1);}
70 if(atoi(argv[3]) < 33){gp2x_deinit();exit(1);}
71 if(atof(argv[4]) > 10){gp2x_deinit();exit(1);}
72 if(atof(argv[4]) < 0.02){gp2x_deinit();exit(1);}
73 if (atoi(argv[1]) == 0)
75 if(atoi(argv[2]) > 36){gp2x_deinit();exit(1);}
76 if(atoi(argv[2]) < -20){gp2x_deinit();exit(1);}
77 set_add_FLCDCLK(atoi(argv[2]));
81 if(atoi(argv[2]) > 10){gp2x_deinit();exit(1);}
82 if(atoi(argv[2]) < -5){gp2x_deinit();exit(1);}
83 set_add_ULCDCLK(atoi(argv[2]));
85 set_FCLK(atoi(argv[3]));
86 set_gamma(atof(argv[4]));
92 printf ("\ngpSP2X v0.9003 Beta by Exophase/ZodTTD\r\n");
93 printf ("cpu_speed by god_at_hell\r\n");
94 printf ("Usage: cpu_speed.gpe [option1] [value1] [option2]...\r\n");
95 printf ("Options:\r\n");
96 printf (" RAM-Options\r\n");
97 printf (" -----------\r\n");
98 printf (" --cas CAS Latency. Delay in clock cycles between the registration \n\t\tof a READ command and the first bit of output data. \n\t\tValid values are 2 and 3 cycles.\r\n");
99 printf (" --trc ACTIVE to ACTIVE /AUTOREFRESH command delay. Defines ACTIVE \n\t\tto ACTIVE/auto refresh command period delay. \n\t\tValid values are from 1 to 16 cycles.\r\n");
100 printf (" --tras ACTIVE to PRECHARGE delay. Defines the delay between the ACTIVE \n\t\tand PRECHARGE commands. \n\t\tValid values are from 1 to 16 cycles.\r\n");
101 printf (" --twr Write recovery time in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
102 printf (" --tmrd LOAD MODE REGISTER command cycle time.\n\t\tValid values are from 1 to 16 cycles.\r\n");
103 printf (" --trfc AUTO REFRESH command period in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
104 printf (" --trp PRECHARGE command period in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
105 printf (" --trcd RAS to CAS Delay in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
106 printf (" --refperd Refresh Period. Defines maximum time period between \n\t\tAUTOREFRESH commands.\n\t\tValid values are from 1 to 65535 (default ~ 250) cycles.\r\n");
107 printf (" --ramdiv Divider for the Memory-Clock which is 1/2 of the CPU-Clock. \n\t\tValid values are from 1 to 8.\r\n");
108 printf ("\n CPU-Options\r\n");
109 printf (" -----------\r\n");
110 printf (" --cpuclk Sets the CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
111 printf (" --cpudiv Divider for the CPU-Clock. \n\t\tValid values are from 1 to 8.\r\n");
112 printf ("\n Display-Options\r\n");
113 printf ("----------------\r\n");
114 printf (" --fpll Sets clockgenerator to fpll (for firmware 1.0 - 1.0.1).\r\n");
115 printf (" --upll Sets clockgenerator to upll (for the rest).\r\n");
116 printf (" --timing Timing Prescaler to eliminate flickering. \n\t\tValid values are: -20 to 36 with fpll.\n\t\t\t\t -6 to 10 with upll.\r\n");
117 printf (" --gamma Regulates the gamma. \n\t\tValid values are from 0.0001 to 15.0000.\r\n");
118 printf ("\n Daemon-Mode \r\n");
119 printf ("----------------\r\n");
120 printf ("Usage: cpu_speed.gpe --daemon [option1] [value1] [option2]...\r\n");
121 printf ("Shutdown: cpu_speed.gpe --kill[-daemon]\r\n");
122 printf ("Options:\r\n");
123 printf (" --min Sets the minimum CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
124 printf (" --max Sets the maximum CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
125 printf (" --start Sets the CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
126 printf (" --step Sets the CPU-Frequency step in Mhz. \n\t\tValid values are from 1 to 340.\r\n");
127 printf (" --hotkey Sets the hotkey. (Default: LR) \n\t\tValid values are a combination of LRXYZAB+-S/@ or ``None''\n\t\t (+- are volume, S is Start, / is Select, @ is Stick).\r\n");
128 printf (" --incr Sets the increment key. (Default: +) \n\t\tValid values are a combination of LRXYZAB+-S/@ or ``None''\n\t\t (+- are volume, S is Start, / is Select, @ is Stick).\r\n");
129 printf (" --decr Sets the decrement key. (Default: -) \n\t\tValid values are a combination of LRXYZAB+-S/@ or ``None''\n\t\t (+- are volume, S is Start, / is Select, @ is Stick).\r\n");
130 printf (" --no-hotkey Alias for --hotkey None.\r\n");
131 printf (" --no-incr Alias for --incr None.\r\n");
132 printf (" --no-decr Alias for --decr None.\r\n");
133 printf (" --foreground Do not switch to daemon mode. (Useful for debugging)\r\n");
134 printf (" --background Switch to daemon mode. (Default)\r\n");
135 printf (" --display Enable on screen display. COMING SOON!\r\n");
136 printf (" --no-display Disable on screen display.\r\n");
137 printf ("\nNOTE:\nThe old commandline-settings are working ... read more about this in the readme\n\n");
140 void cmdline(int argc, char *argv[])
144 char clockgen = get_Clkgen();
145 char var[11][9]={"--cas","--trc","--tras","--twr","--tmrd","--trfc","--trp","--trcd","--ramdiv","--cpuclk","--cpudiv"};
148 for(n=0;n<varis;n++) //initialize the variable-array
158 for(i=1; i<argc; i++)
160 if(strcmp(argv[i], "--fpll") == 0) clockgen = 0;
161 if(strcmp(argv[i], "--upll") == 0) clockgen = 1;
163 for(n=0; n<varis; n++)
165 if(strcmp(argv[i], var[n]) == 0)
167 if(i+1 == argc){printf ("%s is missing it's parameter\r\n",var[n]);gp2x_deinit();exit(1);}
168 val[n] = atoi(argv[i+1]);
171 if(strcmp(argv[i], "--refperd") == 0)
173 if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
174 refperd = atoi(argv[i+1]);
176 if(strcmp(argv[i], "--gamma") == 0)
178 if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
179 gamma = atof(argv[i+1]);
181 if(strcmp(argv[i], "--timing") == 0)
183 if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
184 timing = atoi(argv[i+1]);
192 if(timing < 37) set_add_FLCDCLK(timing);
194 else set_add_FLCDCLK(get_LCDClk(clockgen));
200 if(timing < 11) set_add_ULCDCLK(timing);
202 else set_add_ULCDCLK(get_LCDClk(clockgen));
206 if(refperd-1 < 0xffff) set_REFPERD(refperd-1);
210 if(gamma < 15.) set_gamma(gamma);
214 if(val[0]-2 < 2) set_CAS(val[0]-2);
218 if(val[1]-1 < 16) set_tRC(val[1]-1);
222 if(val[2]-1 < 16) set_tRAS(val[2]-1);
226 if(val[3]-1 < 16) set_tWR(val[3]-1);
230 if(val[4]-1 < 16) set_tMRD(val[4]-1);
234 if(val[5]-1 < 16) set_tRFC(val[5]-1);
238 if(val[6] < 16) set_tRP(val[6]-1);
242 if(val[7]-1 < 16) set_tRCD(val[7]-1);
246 if(val[8]-1 < 8) set_DCLK_Div(val[8]-1);
250 if(val[9] < 341) set_FCLK(val[9]);
254 if(val[10]-1 < 8) set_920_Div(val[10]-1);