wmacpi: Bump to version 1.99r7.
[dockapps.git] / wmacpi / libacpi.h
blobb28687a9c9d1d356f9eac8e7f591b03cdbcd5614
1 #ifndef _LIBACPI_H_
2 #define _LIBACPI_H_
5 #define LIBACPI_VER "0.91"
7 /* Here because we need it for definitions in this file . . . */
8 #define MAX_NAME 128
9 #define MAXBATT 8
10 #define SAMPLES 50
12 typedef enum {
13 REMAIN,
14 TIMER
15 } DspMode;
17 typedef enum {
18 AC,
19 BATT,
20 PS_ERR,
21 } power_state_t;
23 typedef enum {
24 HIGH,
25 MED,
26 LOW,
27 CRIT,
28 HARD_CRIT,
29 BS_ERR,
30 } batt_state_t;
32 typedef enum {
33 CHARGE,
34 DISCHARGE,
35 CH_ERR,
36 } charge_state_t;
38 typedef enum {
39 OK,
40 CRITICAL,
41 CS_ERR,
42 } cap_state_t;
44 typedef struct {
45 /* general info */
46 char name[MAX_NAME];
47 /* these two are conveniences */
48 char info_file[MAX_NAME];
49 char state_file[MAX_NAME];
50 int present;
51 int design_cap; /* assuming mAh */
52 int last_full_cap;
53 int design_voltage; /* in mV */
54 /* state info */
55 cap_state_t capacity_state;
56 charge_state_t charge_state;
57 int present_rate; /* in mAh */
58 int remaining_cap; /* in mAh */
59 int present_voltage; /* in mV */
60 /* calculated states */
61 batt_state_t state;
62 int percentage; /* stored here because this is a per battery thing */
63 int charge_time; /* time left to charge this battery */
64 /* and a flag to indicate that this is valid . . . */
65 int valid;
66 } battery_t;
68 typedef struct {
69 char *name;
70 char state_file[MAX_NAME];
71 power_state_t power;
72 } adapter_t;
74 /* how to calculate the time remaining */
75 enum rtime_mode {
76 RT_RATE, /* using the current rate, as per the ACPI spec */
77 RT_CAP, /* using the remaining capacity over time */
80 typedef struct {
81 int rtime; /* remaining time */
82 int timer; /* how long been on battery? */
83 int crit_level; /* anything below this is critical low */
84 int battery_count; /* number of batteries found */
85 enum rtime_mode rt_mode;
86 battery_t *binfo; /* pointer to the battery being monitored */
87 adapter_t adapter;
88 } global_t;
91 * Moving percentage to the battery is right, but I think we need a global
92 * remaining capacity somewhere, too . . .
96 * To provide a convenient debugging function . . .
98 * It's a macro because I'm too lazy to deal with varargs.
101 #define pdebug(fmt, arg...) \
102 do { \
103 if (verbosity > 2) \
104 fprintf(stderr, fmt, ##arg); \
105 } while (0)
107 #define pinfo(fmt, arg...) \
108 do { \
109 if (verbosity > 1) \
110 fprintf(stderr, fmt, ##arg); \
111 } while (0)
113 #define perr(fmt, arg...) \
114 do { \
115 if (verbosity > 0) \
116 fprintf(stderr, fmt, ##arg); \
117 } while (0)
119 #define pfatal(fmt, arg...) \
120 fprintf(stderr, fmt, ##arg) \
123 /* Since these /are/ needed here . . . */
124 battery_t batteries[MAXBATT];
125 int verbosity;
127 /* check if apm/acpi is enabled, etc */
128 int power_init(global_t *globals);
129 /* reinitialise everything */
130 int power_reinit(global_t *globals);
131 int reinit_ac_adapters(global_t *globals);
132 int reinit_batteries(global_t *globals);
134 /* fill global_t with data */
135 void acquire_batt_info(global_t *globals, int batt);
136 void acquire_all_batt_info(global_t *globals);
137 void acquire_global_info(global_t *globals);
138 void acquire_all_info(global_t *globals);
140 #endif /* _WMACPI_H_ */