tools/intel_gpu_frequency: remove use of getsubopt

getsubopt is not available in android. The "get" option
doesn't really need sub-options, just display all the
current frequency settings (as per discussion with
Ben Widawsky)

Ben v2: Remove the -geff example in the header
Fixed another typo for the --set while there (found by Dave Gordon)

Signed-off-by: Tim Gore <tim.gore@intel.com>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
This commit is contained in:
Tim Gore 2015-01-16 09:12:15 +00:00 committed by Ben Widawsky
parent 0167619bbc
commit 20d6e0f41b
2 changed files with 9 additions and 31 deletions

View File

@ -3,7 +3,7 @@
intel_gpu_frequency: \- manual page for intel_gpu_frequency intel_gpu_frequency: \- manual page for intel_gpu_frequency
.SH SYNOPSIS .SH SYNOPSIS
.B intel_gpu_frequency .B intel_gpu_frequency
[\fI\,-e\/\fR] [\fI\,--min | --max\/\fR] [\fI\,-g (min|max|efficient)\/\fR] [\fI\,-s frequency_mhz\/\fR] [\fI\,-e\/\fR] [\fI\,--min | --max\/\fR] [\fI\,-g\/\fR] [\fI\,-s frequency_mhz\/\fR]
.SH DESCRIPTION .SH DESCRIPTION
\&A program to manipulate Intel GPU frequencies. Intel GPUs \&A program to manipulate Intel GPU frequencies. Intel GPUs
will automatically throttle the frequencies based on system demands, up when will automatically throttle the frequencies based on system demands, up when
@ -19,8 +19,8 @@ safe bet.
\fB\-e\fR \fB\-e\fR
Lock frequency to the most efficient frequency Lock frequency to the most efficient frequency
.TP .TP
\fB\-g\fR, \fB\-\-get=\fR \fB\-g\fR, \fB\-\-get\fR
Get the frequency comma separated list of ("cur"|"min"|"max"|"eff") Get all the current frequency settings
.TP .TP
\fB\-s\fR, \fB\-\-set\fR \fB\-s\fR, \fB\-\-set\fR
Lock frequency to an absolute value (MHz) Lock frequency to an absolute value (MHz)

View File

@ -22,16 +22,13 @@
* *
* Example: * Example:
* Get all frequencies: * Get all frequencies:
* intel_gpu_frequency --get=cur,min,max,eff * intel_gpu_frequency --get
* *
* Same as above: * Same as above:
* intel_gpu_frequency -g * intel_gpu_frequency -g
* *
* Get the efficient frequency:
* intel_gpu_frequency -geff
*
* Lock the GPU frequency to 300MHz: * Lock the GPU frequency to 300MHz:
* intel_gpu_frequency --set min=300 * intel_gpu_frequency --set 300
* *
* Set the maximum frequency to 900MHz: * Set the maximum frequency to 900MHz:
* intel_gpu_frequency --custom max=900 * intel_gpu_frequency --custom max=900
@ -152,7 +149,7 @@ usage(const char *prog)
printf("Usage: %s [-e] [--min | --max] [-g (min|max|efficient)] [-s frequency_mhz]\n\n", prog); printf("Usage: %s [-e] [--min | --max] [-g (min|max|efficient)] [-s frequency_mhz]\n\n", prog);
printf("Options: \n"); printf("Options: \n");
printf(" -e Lock frequency to the most efficient frequency\n"); printf(" -e Lock frequency to the most efficient frequency\n");
printf(" -g, --get= Get the frequency (optional arg: \"cur\"|\"min\"|\"max\"|\"eff\")\n"); printf(" -g, --get Get all the frequency settings\n");
printf(" -s, --set Lock frequency to an absolute value (MHz)\n"); printf(" -s, --set Lock frequency to an absolute value (MHz)\n");
printf(" -c, --custom Set a min, or max frequency \"min=X | max=Y\"\n"); printf(" -c, --custom Set a min, or max frequency \"min=X | max=Y\"\n");
printf(" -m --max Lock frequency to max frequency\n"); printf(" -m --max Lock frequency to max frequency\n");
@ -184,13 +181,6 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)
int c, tmp; int c, tmp;
bool write = false; bool write = false;
char *token[] = {
(char *)info[CUR].name,
(char *)info[MIN].name,
(char *)"eff",
(char *)info[MAX].name
};
/* No args means -g" */ /* No args means -g" */
if (argc == 1) { if (argc == 1) {
for (c = 0; c < act_upon_n; c++) for (c = 0; c < act_upon_n; c++)
@ -200,7 +190,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)
while (1) { while (1) {
int option_index = 0; int option_index = 0;
static struct option long_options[] = { static struct option long_options[] = {
{ "get", optional_argument, NULL, 'g' }, { "get", no_argument, NULL, 'g' },
{ "set", required_argument, NULL, 's' }, { "set", required_argument, NULL, 's' },
{ "custom", required_argument, NULL, 'c'}, { "custom", required_argument, NULL, 'c'},
{ "min", no_argument, NULL, 'i' }, { "min", no_argument, NULL, 'i' },
@ -211,7 +201,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
c = getopt_long(argc, argv, "eg::s:c:midh", long_options, &option_index); c = getopt_long(argc, argv, "egs:c:midh", long_options, &option_index);
if (c == -1) if (c == -1)
break; break;
@ -219,19 +209,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)
case 'g': case 'g':
if (write == true) if (write == true)
fprintf(stderr, "Read and write operations not support simultaneously.\n"); fprintf(stderr, "Read and write operations not support simultaneously.\n");
{
if (optarg) {
char *value, *subopts = optarg;
int x;
while (*subopts != '\0') {
x = getsubopt(&subopts, token, &value);
if (x == -1) {
fprintf(stderr, "Unrecognized option (%s)\n", value);
break;
} else
act_upon[x] = true;
}
} else {
int i; int i;
for (i = 0; i < act_upon_n; i++) for (i = 0; i < act_upon_n; i++)
act_upon[i] = true; act_upon[i] = true;