2011-05-05 03:12:25 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2004-2011, Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2009-01-15 00:08:37 +03:00
|
|
|
#ifndef POWER_MANAGMENT_H
|
|
|
|
#define POWER_MANAGMENT_H
|
|
|
|
|
2011-05-05 03:12:25 +04:00
|
|
|
|
2009-01-15 00:08:37 +03:00
|
|
|
#include <Drivers.h>
|
|
|
|
|
2011-05-05 03:12:25 +04:00
|
|
|
|
2009-01-15 00:08:37 +03:00
|
|
|
// io controls
|
2011-05-05 03:12:25 +04:00
|
|
|
enum {
|
2009-01-15 00:08:37 +03:00
|
|
|
// ioctl response with kMagicFreqID
|
|
|
|
IDENTIFY_DEVICE = B_DEVICE_OP_CODES_END + 20001,
|
2011-05-05 03:12:25 +04:00
|
|
|
|
2009-07-09 21:53:09 +04:00
|
|
|
GET_BATTERY_INFO,
|
|
|
|
GET_EXTENDED_BATTERY_INFO,
|
|
|
|
WATCH_BATTERY,
|
|
|
|
STOP_WATCHING_BATTERY
|
2011-05-05 03:12:25 +04:00
|
|
|
};
|
|
|
|
|
2009-01-15 00:08:37 +03:00
|
|
|
|
2009-07-09 21:53:09 +04:00
|
|
|
// ACPI Battery:
|
|
|
|
// magic id returned by IDENTIFY_DEVICE
|
|
|
|
const uint32 kMagicACPIBatteryID = 17822;
|
|
|
|
|
2011-05-05 03:12:25 +04:00
|
|
|
|
|
|
|
// Our known battery states
|
2009-07-09 21:53:09 +04:00
|
|
|
#define BATTERY_DISCHARGING 0x01
|
|
|
|
#define BATTERY_CHARGING 0x02
|
|
|
|
#define BATTERY_CRITICAL_STATE 0x04
|
|
|
|
|
2020-03-04 00:43:56 +03:00
|
|
|
#define BATTERY_MAX_STRING_LENGTH 32
|
|
|
|
|
2009-07-09 21:53:09 +04:00
|
|
|
|
|
|
|
typedef struct {
|
2020-03-04 00:43:56 +03:00
|
|
|
uint32 state;
|
|
|
|
uint32 current_rate;
|
|
|
|
uint32 capacity;
|
|
|
|
uint32 voltage;
|
2009-07-09 21:53:09 +04:00
|
|
|
} acpi_battery_info;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2020-03-04 00:43:56 +03:00
|
|
|
uint32 power_unit;
|
|
|
|
#define ACPI_BATTERY_UNIT_MW 0
|
|
|
|
#define ACPI_BATTERY_UNIT_MA 1
|
|
|
|
uint32 design_capacity;
|
|
|
|
uint32 last_full_charge;
|
|
|
|
uint32 technology;
|
|
|
|
uint32 design_voltage;
|
|
|
|
uint32 design_capacity_warning;
|
|
|
|
uint32 design_capacity_low;
|
|
|
|
uint32 capacity_granularity_1;
|
|
|
|
uint32 capacity_granularity_2;
|
|
|
|
char model_number[BATTERY_MAX_STRING_LENGTH];
|
|
|
|
char serial_number[BATTERY_MAX_STRING_LENGTH];
|
|
|
|
char type[BATTERY_MAX_STRING_LENGTH];
|
|
|
|
char oem_info[BATTERY_MAX_STRING_LENGTH];
|
|
|
|
// ACPI 4.0 and later
|
|
|
|
uint16 revision;
|
|
|
|
#define ACPI_BATTERY_REVISION_0 0
|
|
|
|
#define ACPI_BATTERY_REVISION_1 1
|
|
|
|
#define ACPI_BATTERY_REVISION_BIF 0xffff
|
|
|
|
uint32 cycles;
|
|
|
|
uint32 accuracy;
|
|
|
|
uint32 max_sampling_time;
|
|
|
|
uint32 min_sampling_time;
|
|
|
|
uint32 max_average_interval;
|
|
|
|
uint32 min_average_interval;
|
|
|
|
// ACPI 6.0 and later
|
|
|
|
uint32 swapping_capability;
|
|
|
|
#define ACPI_BATTERY_SWAPPING_NO 0
|
|
|
|
#define ACPI_BATTERY_SWAPPING_COLD 1
|
|
|
|
#define ACPI_BATTERY_SWAPPING_HOT 2
|
2009-07-09 21:53:09 +04:00
|
|
|
} acpi_extended_battery_info;
|
|
|
|
|
|
|
|
|
2009-01-15 00:08:37 +03:00
|
|
|
#endif
|