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 GET_BATTERY_INFO, 18 GET_EXTENDED_BATTERY_INFO, 19 WATCH_BATTERY, 20 STOP_WATCHING_BATTERY 21 }; 22 23 24 // ACPI Battery: 25 // magic id returned by IDENTIFY_DEVICE 26 const uint32 kMagicACPIBatteryID = 17822; 27 28 29 // Our known battery states 30 #define BATTERY_DISCHARGING 0x01 31 #define BATTERY_CHARGING 0x02 32 #define BATTERY_CRITICAL_STATE 0x04 33 #define BATTERY_NOT_CHARGING 0x08 34 35 #define BATTERY_MAX_STRING_LENGTH 32 36 37 38 typedef struct { 39 uint32 state; 40 uint32 current_rate; 41 uint32 capacity; 42 uint32 voltage; 43 } acpi_battery_info; 44 45 46 typedef struct { 47 uint32 power_unit; 48 #define ACPI_BATTERY_UNIT_MW 0 49 #define ACPI_BATTERY_UNIT_MA 1 50 uint32 design_capacity; 51 uint32 last_full_charge; 52 uint32 technology; 53 uint32 design_voltage; 54 uint32 design_capacity_warning; 55 uint32 design_capacity_low; 56 uint32 capacity_granularity_1; 57 uint32 capacity_granularity_2; 58 char model_number[BATTERY_MAX_STRING_LENGTH]; 59 char serial_number[BATTERY_MAX_STRING_LENGTH]; 60 char type[BATTERY_MAX_STRING_LENGTH]; 61 char oem_info[BATTERY_MAX_STRING_LENGTH]; 62 // ACPI 4.0 and later 63 uint16 revision; 64 #define ACPI_BATTERY_REVISION_0 0 65 #define ACPI_BATTERY_REVISION_1 1 66 #define ACPI_BATTERY_REVISION_BIF 0xffff 67 uint32 cycles; 68 uint32 accuracy; 69 uint32 max_sampling_time; 70 uint32 min_sampling_time; 71 uint32 max_average_interval; 72 uint32 min_average_interval; 73 // ACPI 6.0 and later 74 uint32 swapping_capability; 75 #define ACPI_BATTERY_SWAPPING_NO 0 76 #define ACPI_BATTERY_SWAPPING_COLD 1 77 #define ACPI_BATTERY_SWAPPING_HOT 2 78 } acpi_extended_battery_info; 79 80 81 #endif 82