small bit of style cleanup; added additional checks to see if a battery was damaged or it is just an empty slot
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41319 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
/*
|
||||
* Copyright 2004-2011, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef POWER_MANAGMENT_H
|
||||
#define POWER_MANAGMENT_H
|
||||
|
||||
|
||||
#include <Drivers.h>
|
||||
|
||||
|
||||
// io controls
|
||||
enum {
|
||||
// ioctl response with kMagicFreqID
|
||||
@@ -25,9 +31,9 @@ enum {
|
||||
GET_EXTENDED_BATTERY_INFO,
|
||||
WATCH_BATTERY,
|
||||
STOP_WATCHING_BATTERY
|
||||
|
||||
};
|
||||
|
||||
|
||||
// CPU Frequence:
|
||||
// magic id returned by IDENTIFY_DEVICE
|
||||
const uint32 kMagicFreqID = 48921;
|
||||
@@ -35,6 +41,7 @@ const uint32 kMagicFreqID = 48921;
|
||||
|
||||
#define MAX_CPU_FREQUENCY_STATES 10
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16 frequency; // [Mhz]
|
||||
uint16 volts;
|
||||
@@ -47,6 +54,8 @@ typedef struct {
|
||||
// magic id returned by IDENTIFY_DEVICE
|
||||
const uint32 kMagicACPIBatteryID = 17822;
|
||||
|
||||
|
||||
// Our known battery states
|
||||
#define BATTERY_DISCHARGING 0x01
|
||||
#define BATTERY_CHARGING 0x02
|
||||
#define BATTERY_CRITICAL_STATE 0x04
|
||||
|
||||
@@ -75,7 +75,8 @@ ReadBatteryStatus(battery_driver_cookie* cookie, acpi_battery_info* batteryStatu
|
||||
? pointer->data.integer : -1;
|
||||
|
||||
/* If key values are all < 0, it is likely that the battery slot is empty
|
||||
or the battery is damaged. Set BATTERY_CRITICAL_STATE */
|
||||
* or the battery is damaged. Set BATTERY_CRITICAL_STATE
|
||||
*/
|
||||
if (batteryStatus->voltage < 0
|
||||
&& batteryStatus->current_rate < 0
|
||||
&& batteryStatus->capacity < 0) {
|
||||
@@ -88,6 +89,7 @@ exit:
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ReadBatteryInfo(battery_driver_cookie* cookie,
|
||||
acpi_extended_battery_info* batteryInfo)
|
||||
|
||||
@@ -136,8 +136,14 @@ BatteryInfoView::_FillStringList()
|
||||
fontString->string = B_TRANSLATE("Battery charging");
|
||||
else if (fBatteryInfo.state & BATTERY_DISCHARGING)
|
||||
fontString->string = B_TRANSLATE("Battery discharging");
|
||||
else if (fBatteryInfo.state & BATTERY_CRITICAL_STATE)
|
||||
else if (fBatteryInfo.state & BATTERY_CRITICAL_STATE
|
||||
&& strcmp(fBatteryExtendedInfo.model_number, "")
|
||||
&& strcmp(fBatteryExtendedInfo.serial_number, "")
|
||||
&& strcmp(fBatteryExtendedInfo.type, "")
|
||||
&& strcmp(fBatteryExtendedInfo.oem_info, ""))
|
||||
fontString->string = B_TRANSLATE("Empty battery slot");
|
||||
else if (fBatteryInfo.state & BATTERY_CRITICAL_STATE)
|
||||
fontString->string = B_TRANSLATE("Damaged battery");
|
||||
else
|
||||
fontString->string = B_TRANSLATE("Battery unused");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user