1 Common subdirectories: powertop-1.13/kernel-patches and powertop-patched/kernel-patches
2 Common subdirectories: powertop-1.13/po and powertop-patched/po
3 diff -u powertop-1.13/powertop.c powertop-patched/powertop.c
4 --- powertop-1.13/powertop.c 2010-07-20 01:08:21.000000000 +0200
5 +++ powertop-patched/powertop.c 2011-10-20 14:34:41.163951192 +0200
7 qsort (lines, linehead, sizeof (struct line), line_compare);
12 -int print_battery_proc_acpi(void)
15 - struct dirent *dirent;
22 - dir = opendir("/proc/acpi/battery");
26 - while ((dirent = readdir(dir))) {
28 - double voltage = 0.0;
29 - double amperes_drawn = 0.0;
30 - double watts_drawn = 0.0;
31 - double amperes_left = 0.0;
32 - double watts_left = 0.0;
35 - if (strlen(dirent->d_name) < 3)
38 - sprintf(filename, "/proc/acpi/battery/%s/state", dirent->d_name);
39 - file = fopen(filename, "r");
42 - memset(line, 0, 1024);
43 - while (fgets(line, 1024, file) != NULL) {
45 - if (strstr(line, "present:") && strstr(line, "no"))
48 - if (strstr(line, "charging state:")
49 - && !strstr(line, "discharging"))
51 - c = strchr(line, ':');
56 - if (strstr(line, "present voltage"))
57 - voltage = strtoull(c, NULL, 10) / 1000.0;
59 - if (strstr(line, "remaining capacity") && strstr(c, "mW"))
60 - watts_left = strtoull(c, NULL, 10) / 1000.0;
62 - if (strstr(line, "remaining capacity") && strstr(c, "mAh"))
63 - amperes_left = strtoull(c, NULL, 10) / 1000.0;
65 - if (strstr(line, "present rate") && strstr(c, "mW"))
66 - watts_drawn = strtoull(c, NULL, 10) / 1000.0 ;
68 - if (strstr(line, "present rate") && strstr(c, "mA"))
69 - amperes_drawn = strtoull(c, NULL, 10) / 1000.0;
75 - rate += watts_drawn + voltage * amperes_drawn;
77 - cap += watts_left + voltage * amperes_left;
82 - if (prev_bat_cap - cap < 0.001 && rate < 0.001)
84 - if (!last_bat_time) {
85 - last_bat_time = prev_bat_time = time(NULL);
86 - last_bat_cap = prev_bat_cap = cap;
88 - if (time(NULL) - last_bat_time >= 400) {
89 - prev_bat_cap = last_bat_cap;
90 - prev_bat_time = last_bat_time;
91 - last_bat_time = time(NULL);
95 - show_acpi_power_line(rate, cap, prev_bat_cap - cap, time(NULL) - prev_bat_time);
99 int print_battery_proc_pmu(void)
106 - if (print_battery_proc_acpi())
109 if (print_battery_proc_pmu())
113 while ((dirent = readdir(dir))) {
115 double voltage = 0.0;
116 - double amperes_drawn = 0.0;
117 double watts_drawn = 0.0;
118 double watts_left = 0.0;
121 watts_left *= strtoull(line, NULL, 10) / 1000000.0;
124 - sprintf(filename, "/sys/class/power_supply/%s/current_now", dirent->d_name);
125 + sprintf(filename, "/sys/class/power_supply/%s/power_now", dirent->d_name);
126 file = fopen(filename, "r");
128 + sprintf(filename, "/sys/class/power_supply/%s/current_now", dirent->d_name);
129 + file = fopen(filename, "r");
133 memset(line, 0, 1024);
138 - rate += watts_drawn + voltage * amperes_drawn;
139 + rate += watts_drawn;