Lines Matching +full:switching +full:- +full:freq

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
98 static int set_freq(int freq);
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);
278 set_freq(int freq)
281 if (sysctl(freq_mib, 4, NULL, NULL, &freq, sizeof(freq))) {
283 return (-1);
290 get_freq_id(int freq, int *freqs, int numfreqs)
295 if (freqs[i] < freq)
299 return (i - 1);
370 if (hdr != NULL && hdr->nlmsg_type != NLMSG_ERROR) {
391 warnx("lost devd connection, switching to sysctl");
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;
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");
579 int freq, curfreq, initfreq, *freqs, i, j, *mwatts, numfreqs, load;
580 int minfreq = -1, maxfreq = -1;
600 while ((ch = getopt(argc, argv, "a:b:i:m:M:Nn:p:P:r:s:v")) != -1)
676 if (sysctlnametomib("dev.cpu.0.freq", freq_mib, &len))
677 err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
688 errx(1, "no CPU frequencies in user-specified range");
720 freq = initfreq = curfreq = get_freq();
722 if (freq < 1)
723 freq = 1;
727 * user-defined range, adjust it to be within the user-defined range.
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) {
751 warn("error setting CPU freq %d",
752 freqs[numfreqs - 1]);
756 printf("CPU frequency is above user-defined "
761 warn("error setting CPU freq %d",
824 if (mwatts[i] != -1)
831 freq = freqs[numfreqs - 1];
832 if (curfreq != freq) {
836 modes[acline_status], freq);
839 if (set_freq(freq) != 0) {
840 warn("error setting CPU freq %d",
841 freq);
850 freq = freqs[0];
851 if (curfreq != freq) {
855 modes[acline_status], freq);
858 if (set_freq(freq) != 0) {
859 warn("error setting CPU freq %d",
860 freq);
877 freq *= 2;
879 freq = freq * load / cpu_running_mark;
880 if (freq > freqs[0])
881 freq = freqs[0];
884 freq * 7 / 8, freqs, numfreqs)] *
886 freq = freq * 7 / 8;
887 if (freq < freqs[numfreqs - 1])
888 freq = freqs[numfreqs - 1];
893 freq *= 4;
895 freq = freq * load * 2 / cpu_running_mark;
896 if (freq > freqs[0] * 2)
897 freq = freqs[0] * 2;
900 freq * 31 / 32, freqs, numfreqs)] *
902 freq = freq * 31 / 32;
903 if (freq < freqs[numfreqs - 1])
904 freq = freqs[numfreqs - 1];
908 printf("load %3d%%, current freq %4d MHz (%2d), wanted freq %4d MHz\n",
909 load, curfreq, i, freq);
911 j = get_freq_id(freq, freqs, numfreqs);