Lines Matching +full:switch +full:- +full:mode +full:- +full:frequency

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
105 static void parse_mode(char *arg, int *mode, int ch);
135 static int apm_fd = -1;
137 static int devd_pipe = -1;
147 * threads are processing requests as a pipeline -- running one at
185 total += cp_times[cpu * CPUSTATES + i] -
190 excl = cp_times[cpu * CPUSTATES + CP_IDLE] -
193 excl += cp_times[cpu * CPUSTATES + CP_NICE] -
195 *load += 100 - excl * 100 / total;
212 return (-1);
214 return (-1);
217 return (-1);
227 return (-1);
232 return (-1);
242 return (-1);
244 if (((*freqs)[j] >= minfreq || minfreq == -1) &&
245 ((*freqs)[j] <= maxfreq || maxfreq == -1))
255 return (-1);
271 warn("error reading current CPU frequency");
283 return (-1);
299 return (i - 1);
304 * to APM. If nothing succeeds, we'll just run in default mode.
370 if (hdr != NULL && hdr->nlmsg_type != NLMSG_ERROR) {
422 apm_fd = -1;
481 sizeof(group)) == -1) {
497 return (-1);
503 sizeof(devd_addr)) == -1) {
507 devd_pipe = -1;
508 return (-1);
519 devd_pipe = -1;
523 parse_mode(char *arg, int *mode, int ch)
527 *mode = MODE_MIN;
529 *mode = MODE_MAX;
531 *mode = MODE_ADAPTIVE;
533 *mode = MODE_HIADAPTIVE;
535 errx(1, "bad option: -%c %s", (char)ch, optarg);
552 errx(1, "bad option: -%c %s", (char)ch, optarg);
567 "usage: powerd [-v] [-a mode] [-b mode] [-i %%] [-m freq] [-M freq] [-N] [-n mode] [-p ival] [-r %%] [-s source] [-P pidfile]\n");
580 int minfreq = -1, maxfreq = -1;
581 int ch, mode, mode_ac, mode_battery, mode_none, idle, to;
586 /* Default mode for all AC states is adaptive. */
600 while ((ch = getopt(argc, argv, "a:b:i:m:M:Nn:p:P:r:s:v")) != -1)
601 switch (ch) {
622 warnx("%d is not a valid CPU frequency",
630 warnx("%d is not a valid CPU frequency",
666 mode = mode_none;
677 err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
688 errx(1, "no CPU frequencies in user-specified range");
690 /* Run in the background unless in verbose mode. */
703 warn("cannot enter daemon mode, exiting");
726 * If we are in adaptive mode and the current frequency is outside the
727 * user-defined range, adjust it to be within the user-defined range.
738 /* Read the current frequency. */
742 warn("error reading current CPU frequency");
744 if (curfreq < freqs[numfreqs - 1]) {
746 printf("CPU frequency is below user-defined "
747 "minimum; changing frequency to %d "
748 "MHz\n", freqs[numfreqs - 1]);
750 if (set_freq(freqs[numfreqs - 1]) != 0) {
752 freqs[numfreqs - 1]);
756 printf("CPU frequency is above user-defined "
757 "maximum; changing frequency to %d "
780 if (mode == MODE_HIADAPTIVE || idle < 120)
799 /* Read the current AC status and record the mode. */
801 switch (acline_status) {
803 mode = mode_ac;
806 mode = mode_battery;
809 mode = mode_none;
815 /* Read the current frequency. */
824 if (mwatts[i] != -1)
829 /* Always switch to the lowest frequency in min mode. */
830 if (mode == MODE_MIN) {
831 freq = freqs[numfreqs - 1];
835 "changing frequency to %d MHz\n",
848 /* Always switch to the highest frequency in max mode. */
849 if (mode == MODE_MAX) {
854 "changing frequency to %d MHz\n",
867 /* Adaptive mode; get the current CPU usage times. */
874 if (mode == MODE_ADAPTIVE) {
887 if (freq < freqs[numfreqs - 1])
888 freq = freqs[numfreqs - 1];
903 if (freq < freqs[numfreqs - 1])
904 freq = freqs[numfreqs - 1];
920 warn("error setting CPU frequency %d",
925 warn("error setting CPU frequency %d", initfreq);