xref: /haiku/headers/private/device/power_managment.h (revision b46615c55ad2c8fe6de54412055a0713da3d610a)
1 /*
2  * Copyright 2004-2011, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef POWER_MANAGMENT_H
6 #define POWER_MANAGMENT_H
7 
8 
9 #include <Drivers.h>
10 
11 
12 // io controls
13 enum {
14 	// ioctl response with kMagicFreqID
15 	IDENTIFY_DEVICE = B_DEVICE_OP_CODES_END + 20001,
16 
17 	// CPU Frequence:
18 	// get a list of freq_info, the list is terminated with a element with
19 	// frequency = 0
20 	GET_CPU_FREQ_STATES = B_DEVICE_OP_CODES_END + 20005,
21 	// get and set a freq_info
22 	GET_CURENT_CPU_FREQ_STATE,
23 	SET_CPU_FREQ_STATE,
24 	// start watching for frequency changes, ioctl blocks until the frequency
25 	// has changed
26 	WATCH_CPU_FREQ,
27 	// stop all watching ioctl, ioctl return B_ERROR
28 	STOP_WATCHING_CPU_FREQ,
29 
30 	GET_BATTERY_INFO,
31 	GET_EXTENDED_BATTERY_INFO,
32 	WATCH_BATTERY,
33 	STOP_WATCHING_BATTERY
34 };
35 
36 
37 // CPU Frequence:
38 // magic id returned by IDENTIFY_DEVICE
39 const uint32 kMagicFreqID = 48921;
40 
41 
42 #define MAX_CPU_FREQUENCY_STATES 10
43 
44 
45 typedef struct {
46 	uint16			frequency;	// [Mhz]
47 	uint16			volts;
48 	uint16			id;
49 	int				power;
50 } freq_info;
51 
52 
53 // ACPI Battery:
54 // magic id returned by IDENTIFY_DEVICE
55 const uint32 kMagicACPIBatteryID = 17822;
56 
57 
58 // Our known battery states
59 #define BATTERY_DISCHARGING		0x01
60 #define BATTERY_CHARGING		0x02
61 #define BATTERY_CRITICAL_STATE	0x04
62 
63 
64 typedef struct {
65 	int		state;
66 	int		current_rate;
67 	int 	capacity;
68 	int		voltage;
69 } acpi_battery_info;
70 
71 
72 typedef struct {
73 	int		power_unit;
74 	int		design_capacity;
75 	int		last_full_charge;
76 	int		technology;
77 	int 	design_voltage;
78 	int		design_capacity_warning;
79 	int		design_capacity_low;
80 	int		capacity_granularity_1;
81 	int		capacity_granularity_2;
82 	char	model_number[32];
83 	char	serial_number[32];
84 	char	type[32];
85 	char	oem_info[32];
86 } acpi_extended_battery_info;
87 
88 
89 #endif
90