/***************************************************************************
*
* acpi.c : Main routines for setting battery, AC adapter, and lid properties
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Licensed under the Academic Free License version 2.1
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <unistd.h>
#include <strings.h>
#include <string.h>
#include <kstat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/acpi_drv.h>
#include <libhal.h>
#include "../hald/device_info.h"
#include "../hald/hald_dbus.h"
#include "acpi.h"
static void
{
if (dbus_error_is_set(error)) {
}
}
{
HAL_DEBUG(("laptop_panel_update() enter"));
return (FALSE);
}
return (FALSE);
}
"Generic Backlight Device");
"laptop_panel");
}
HAL_DEBUG(("ac_adapter_present() exit"));
return (TRUE);
}
{
int lid_state;
HAL_DEBUG(("lid_update() enter"));
return (FALSE);
}
TRUE);
return (FALSE);
}
if (lid_state != 0) {
/* lid open */
} else {
/* lid closed */
}
TRUE);
"lid");
"Lid Switch");
"button");
} else {
return (FALSE);
}
if (lid_state != 0) {
/* lid open */
} else {
/* lid closed */
}
}
HAL_DEBUG(("update_lid() exit"));
return (TRUE);
}
static void
{
int pow;
HAL_DEBUG(("ac_adapter_present() enter"));
return;
}
return;
}
if (pow > 0) {
TRUE);
} else {
FALSE);
}
HAL_DEBUG(("ac_adapter_present() exit"));
}
static void
{
HAL_DEBUG(("battery_remove() enter"));
&error);
&error);
"battery.charge_level.current", &error);
&error);
&error);
&error);
"battery.rechargeable.is_discharging", &error);
"battery.rechargeable.is_charging", &error);
&error);
&error);
&error);
&error);
&error);
&error);
"battery.reporting.granularity_2", &error);
"battery.reporting.granularity_1", &error);
&error);
&error);
&error);
&error);
&error);
&error);
HAL_DEBUG(("battery_remove() exit"));
}
static void
{
return;
}
}
static void
{
int reporting_rate;
int reporting_current;
int reporting_lastfull;
int design_voltage;
int present_voltage;
char *reporting_unit;
int remaining_time;
int remaining_percentage;
static int counter = 0;
HAL_DEBUG(("battery_dynamic_update() enter"));
return;
}
/* No need to continue if battery is essentially idle. */
return;
}
}
}
/* get all the data we know */
"battery.reporting.unit", &error);
"battery.reporting.last_full", &error);
/*
* Convert mAh to mWh since util_compute_time_remaining() works
* for mWh.
*/
"battery.voltage.design", &error);
/*
* If the present_voltage is inaccurate, set it to the
* design_voltage.
*/
(present_voltage <= 0) ||
(present_voltage > design_voltage)) {
}
1000;
1000;
}
/* Make sure the current charge does not exceed the full charge */
if (reporting_current > reporting_lastfull) {
}
if (!charging && !discharging) {
counter++;
reporting_rate = 0;
}
HAL_DEBUG(("Cannot allocate changeset"));
return;
}
"battery.charge_level.last_full", reporting_lastfull);
"battery.charge_level.current", reporting_current);
/*
* Some batteries give bad remaining_time estimates relative to
* the charge level.
*/
}
if (remaining_percentage > 0) {
"battery.charge_level.percentage", remaining_percentage);
} else {
}
}
/*
* remaining_percentage is more accurate so we handle cases
* where the remaining_time cannot be correct.
*/
!discharging)) {
remaining_time = 0;
}
if (remaining_time < 0) {
"battery.remaining_time", &error);
} else if (remaining_time >= 0) {
"battery.remaining_time", remaining_time);
}
HAL_DEBUG(("battery_dynamic_update() exit"));
}
static gboolean
{
const char *technology;
int reporting_design;
int reporting_warning;
int reporting_low;
int reporting_gran1;
int reporting_gran2;
int voltage_design;
HAL_DEBUG(("battery_static_update() enter"));
return (FALSE);
}
HAL_DEBUG(("Cannot allocate changeset"));
return (FALSE);
}
if (technology != NULL) {
"battery.reporting.technology", technology);
}
"battery.reporting.unit", "mAh");
} else {
"battery.reporting.unit", "mWh");
}
/* convert to mWh */
"battery.charge_level.unit", "mWh");
"battery.charge_level.design",
"battery.charge_level.warning",
"battery.charge_level.low",
"battery.charge_level.granularity_1",
"battery.charge_level.granularity_2",
} else {
"battery.charge_level.unit", "mWh");
}
"battery.charge_level.design", reporting_design);
"battery.charge_level.warning", reporting_warning);
"battery.charge_level.low", reporting_low);
"battery.charge_level.granularity_1", reporting_gran1);
"battery.charge_level.granularity_2", reporting_gran2);
}
HAL_DEBUG(("battery_static_update() exit"));
return (TRUE);
}
{
HAL_DEBUG(("battery_update() enter"));
"Battery Bay", &error);
&error);
} else {
return (FALSE);
}
} else {
}
&error)) {
HAL_DEBUG(("battery_update(): battery is NOT present"));
} else {
HAL_DEBUG(("battery_update(): battery is present"));
"primary", &error);
&error) == LIBHAL_PROPERTY_TYPE_INVALID) {
}
}
HAL_DEBUG(("battery_update() exit"));
return (TRUE);
}
static gboolean
{
int i;
int num_devices;
char **battery_devices;
int fd;
HAL_DEBUG(("battery_update_all() enter"));
NULL) {
for (i = 0; i < num_devices; i++) {
battery_devices[i])) == -1) {
continue;
}
fd);
}
}
}
HAL_DEBUG(("battery_update_all() exit"));
return (TRUE);
}
{
HAL_DEBUG(("ac_adapter_update() enter"));
return (FALSE);
}
"AC Adapter");
"ac_adapter");
}
HAL_DEBUG(("ac_adapter_update() exit"));
return (TRUE);
}
static gboolean
{
int i;
int num_devices;
char **ac_adapter_devices;
int fd;
HAL_DEBUG(("ac_adapter_update_all() enter"));
NULL) {
for (i = 0; i < num_devices; i++) {
== -1) {
continue;
}
}
}
HAL_DEBUG(("ac_adapter_update_all() exit"));
return (TRUE);
}
{
HAL_DEBUG(("update_devices() enter"));
HAL_DEBUG(("update_devices() exit"));
return (TRUE);
}
int
{
char *devfs_path;
"solaris.devfs_path", &error);
if (devfs_path == NULL) {
return (-1);
}
}