wmacpi: Fix -Wunused-but-set-variable compiler warning.
[dockapps.git] / wmacpi / libacpi.h
blobafb38c098d0d1cbf251279610472e20f1d7f723c
1 #ifndef _LIBACPI_H_
2 #define _LIBACPI_H_
5 #define LIBACPI_VER "0.95"
7 /* Here because we need it for definitions in this file . . . */
8 #define MAX_NAME 128
9 #define MAXBATT 8
10 #define SAMPLES 50
11 #define CAP_SAMPLES (SAMPLES*10)
13 typedef enum {
14 REMAIN,
15 TIMER
16 } DspMode;
18 typedef enum {
19 AC,
20 BATT,
21 PS_ERR,
22 } power_state_t;
24 typedef enum {
25 HIGH,
26 MED,
27 LOW,
28 CRIT,
29 BS_ERR,
30 } batt_state_t;
32 typedef enum {
33 CHARGE,
34 DISCHARGE,
35 FULL,
36 NO_CHARGE,
37 CH_ERR,
38 } charge_state_t;
40 typedef enum {
41 SYSFS_CAPA_ENERGY,
42 SYSFS_CAPA_CHARGE,
43 SYSFS_CAPA_PERCENT,
44 SYSFS_CAPA_ERR,
45 } sysfs_capa_t;
47 typedef struct {
48 /* general info */
49 char name[MAX_NAME];
50 /* these two are conveniences */
51 char info_file[MAX_NAME];
52 char state_file[MAX_NAME];
53 /* sysfs capacity mode */
54 sysfs_capa_t sysfs_capa_mode;
55 int present;
56 int design_cap; /* assuming mAh */
57 int last_full_cap;
58 int design_voltage; /* in mV */
59 /* state info */
60 charge_state_t charge_state;
61 int present_rate; /* in mAh */
62 int remaining_cap; /* in mAh */
63 int present_voltage; /* in mV */
64 /* calculated states */
65 batt_state_t state;
66 int percentage; /* stored here because this is a per battery thing */
67 int charge_time; /* time left to charge this battery */
68 /* and a flag to indicate that this is valid . . . */
69 int valid;
70 /* number of times we've gotten bad info on this battery's present rate */
71 int bad_count;
72 } battery_t;
74 typedef struct {
75 char *name;
76 char state_file[MAX_NAME];
77 power_state_t power;
78 } adapter_t;
80 /* how to calculate the time remaining */
81 enum rtime_mode {
82 RT_RATE, /* using the current rate, as per the ACPI spec */
83 RT_CAP, /* using the remaining capacity over time */
86 typedef struct {
87 int rtime; /* remaining time */
88 int timer; /* how long been on battery? */
89 int crit_level; /* anything below this is critical low */
90 int battery_count; /* number of batteries found */
91 enum rtime_mode rt_mode; /* remaining time mode */
92 int rt_forced; /* was our rt_mode forced? if so, we do what we were told */
93 battery_t *binfo; /* pointer to the battery being monitored */
94 adapter_t adapter;
95 } global_t;
98 * Moving percentage to the battery is right, but I think we need a global
99 * remaining capacity somewhere, too . . .
103 * To provide a convenient debugging function . . .
105 * It's a macro because I'm too lazy to deal with varargs.
108 #define pdebug(fmt, arg...) \
109 do { \
110 if (verbosity > 2) \
111 fprintf(stderr, fmt, ##arg); \
112 } while (0)
114 #define pinfo(fmt, arg...) \
115 do { \
116 if (verbosity > 1) \
117 fprintf(stderr, fmt, ##arg); \
118 } while (0)
120 #define perr(fmt, arg...) \
121 do { \
122 if (verbosity > 0) \
123 fprintf(stderr, fmt, ##arg); \
124 } while (0)
126 #define pfatal(fmt, arg...) \
127 fprintf(stderr, fmt, ##arg) \
130 /* Since these /are/ needed here . . . */
131 battery_t batteries[MAXBATT];
132 int verbosity;
134 /* check if apm/acpi is enabled, etc */
135 int power_init(global_t *globals);
136 /* reinitialise everything */
137 int power_reinit(global_t *globals);
138 int reinit_ac_adapters(global_t *globals);
139 int reinit_batteries(global_t *globals);
141 /* fill global_t with data */
142 void acquire_batt_info(global_t *globals, int batt);
143 void acquire_all_batt_info(global_t *globals);
144 void acquire_global_info(global_t *globals);
145 void acquire_all_info(global_t *globals);
147 #endif /* _WMACPI_H_ */