Lines Matching +full:ac +full:- +full:power

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
84 "AC",
96 static int read_freqs(int *numfreqs, int **freqs, int **power,
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;
205 read_freqs(int *numfreqs, int **freqs, int **power, int minfreq, int maxfreq)
212 return (-1);
214 return (-1);
217 return (-1);
227 return (-1);
229 if ((*power = malloc(*numfreqs * sizeof(int))) == NULL) {
232 return (-1);
238 if (sscanf(p, "%d/%d", &(*freqs)[j], &(*power)[i]) != 2) {
241 free(*power);
242 return (-1);
244 if (((*freqs)[j] >= minfreq || minfreq == -1) &&
245 ((*freqs)[j] <= maxfreq || maxfreq == -1))
254 free(*power);
255 return (-1);
283 return (-1);
299 return (i - 1);
303 * Try to use ACPI to find the AC line status. If this fails, fall back
320 warnx("using sysctl for AC line status");
326 warnx("using sysctl for AC line status");
332 warnx("using APM for AC line status");
336 warnx("unable to determine AC line status");
370 if (hdr != NULL && hdr->nlmsg_type != NLMSG_ERROR) {
422 apm_fd = -1;
447 warnx("using netlink for AC line status");
456 warnx("using devd for AC line status");
481 sizeof(group)) == -1) {
497 return (-1);
503 sizeof(devd_addr)) == -1) {
507 devd_pipe = -1;
508 return (-1);
519 devd_pipe = -1;
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;
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)
677 err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
688 errx(1, "no CPU frequencies in user-specified range");
711 /* Decide whether to use ACPI or APM to read the AC line status. */
727 * user-defined range, adjust it to be within the user-defined range.
731 errx(1, "invalid AC line status %d", acline_status);
744 if (curfreq < freqs[numfreqs - 1]) {
746 printf("CPU frequency is below user-defined "
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 "
799 /* Read the current AC status and record the mode. */
812 errx(1, "invalid AC line status %d", acline_status);
823 /* Keep a sum of all power actually used. */
824 if (mwatts[i] != -1)
831 freq = freqs[numfreqs - 1];
834 printf("now operating on %s power; "
853 printf("now operating on %s power; "
887 if (freq < freqs[numfreqs - 1])
888 freq = freqs[numfreqs - 1];
903 if (freq < freqs[numfreqs - 1])
904 freq = freqs[numfreqs - 1];