acpiio.h revision 143771
167761Smsmith/*-
2119097Stakawata * Copyright (c) 1999 Takanori Watanabe <takawata@jp.freebsd.org>
367761Smsmith * Copyright (c) 1999 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
467761Smsmith * All rights reserved.
567761Smsmith *
667761Smsmith * Redistribution and use in source and binary forms, with or without
767761Smsmith * modification, are permitted provided that the following conditions
867761Smsmith * are met:
967761Smsmith * 1. Redistributions of source code must retain the above copyright
1067761Smsmith *    notice, this list of conditions and the following disclaimer.
1167761Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1267761Smsmith *    notice, this list of conditions and the following disclaimer in the
1367761Smsmith *    documentation and/or other materials provided with the distribution.
1467761Smsmith *
1567761Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1667761Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1767761Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1867761Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1967761Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2067761Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2167761Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2267761Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2367761Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2467761Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2567761Smsmith * SUCH DAMAGE.
2667761Smsmith *
27143002Sobrien * $FreeBSD: head/sys/dev/acpica/acpiio.h 143771 2005-03-17 22:42:49Z njl $
2867761Smsmith */
2967761Smsmith
30142753Snjl#ifndef _ACPIIO_H_
31142753Snjl#define _ACPIIO_H_
32142753Snjl
3369744Smsmith/*
3469744Smsmith * Core ACPI subsystem ioctls
3569744Smsmith */
3667761Smsmith#define ACPIIO_SETSLPSTATE	_IOW('P', 3, int)
3767761Smsmith
3878662Siwasakistruct acpi_battdesc {
39143771Snjl    int	 type;				/* battery type */
40119529Snjl    int	 phys_unit;			/* physical unit of devclass */
4178662Siwasaki};
4278662Siwasaki
4378662Siwasaki#define ACPI_BATT_TYPE_CMBAT		0x0000
4478662Siwasaki#define ACPI_BATT_TYPE_SMBAT		0x0001
4578662Siwasaki
4678662Siwasakistruct acpi_battinfo {
47119529Snjl    int	 cap;				/* percent */
48143771Snjl    int	 min;				/* remaining time (in minutes) */
49119529Snjl    int	 state;				/* battery state */
5078662Siwasaki};
5178662Siwasaki
5270271Stakawata#define ACPI_CMBAT_MAXSTRLEN 32
5370271Stakawatastruct acpi_bif {
54120036Snjl    u_int32_t units;			/* 0 for mWh, 1 for mAh */
55119529Snjl    u_int32_t dcap;			/* Design Capacity */
56119529Snjl    u_int32_t lfcap;			/* Last Full capacity */
57120036Snjl    u_int32_t btech;			/* Battery Technology */
58119529Snjl    u_int32_t dvol;			/* Design voltage (mV) */
59119529Snjl    u_int32_t wcap;			/* WARN capacity */
60119529Snjl    u_int32_t lcap;			/* Low capacity */
61130914Sbrueffer    u_int32_t gra1;			/* Granularity 1 (Warn to Low) */
62130914Sbrueffer    u_int32_t gra2;			/* Granularity 2 (Full to Warn) */
63119529Snjl    char model[ACPI_CMBAT_MAXSTRLEN];	/* model identifier */
64119529Snjl    char serial[ACPI_CMBAT_MAXSTRLEN];	/* Serial number */
65119529Snjl    char type[ACPI_CMBAT_MAXSTRLEN];	/* Type */
66119529Snjl    char oeminfo[ACPI_CMBAT_MAXSTRLEN];	/* OEM infomation */
6770271Stakawata};
6870271Stakawata
6970271Stakawatastruct acpi_bst {
70119529Snjl    u_int32_t state;			/* Battery State */
71119529Snjl    u_int32_t rate;			/* Present Rate */
72119529Snjl    u_int32_t cap;			/* Remaining Capacity */
73119529Snjl    u_int32_t volt;			/* Present Voltage */
7470271Stakawata};
7570271Stakawata
7678662Siwasaki#define ACPI_BATT_STAT_DISCHARG		0x0001
7778662Siwasaki#define ACPI_BATT_STAT_CHARGING		0x0002
7878662Siwasaki#define ACPI_BATT_STAT_CRITICAL		0x0004
7978662Siwasaki#define ACPI_BATT_STAT_NOT_PRESENT	0x0007
8078662Siwasaki#define ACPI_BATT_STAT_MAX		0x0007
8178662Siwasaki
8278662Siwasakiunion acpi_battery_ioctl_arg {
83143771Snjl    int			 unit;	/* argument: logical unit (-1 = overall) */
8478662Siwasaki
85143771Snjl    struct acpi_battdesc battdesc;
86143771Snjl    struct acpi_battinfo battinfo;
8778662Siwasaki
88143771Snjl    struct acpi_bif	 bif;
89143771Snjl    struct acpi_bst	 bst;
9070340Siwasaki};
9170340Siwasaki
92143771Snjl/* Common battery ioctls */
93119529Snjl#define ACPIIO_BATT_GET_UNITS	  _IOR('B', 0x01, int)
94119529Snjl#define ACPIIO_BATT_GET_TYPE	  _IOR('B', 0x02, union acpi_battery_ioctl_arg)
9578662Siwasaki#define ACPIIO_BATT_GET_BATTINFO _IOWR('B', 0x03, union acpi_battery_ioctl_arg)
9678662Siwasaki#define ACPIIO_BATT_GET_BATTDESC _IOWR('B', 0x04, union acpi_battery_ioctl_arg)
97143771Snjl#define ACPIIO_BATT_GET_BIF	 _IOWR('B', 0x10, union acpi_battery_ioctl_arg)
98143771Snjl#define ACPIIO_BATT_GET_BST	 _IOWR('B', 0x11, union acpi_battery_ioctl_arg)
9970340Siwasaki
100143771Snjl/* Control Method battery ioctls (deprecated) */
101143771Snjl#define ACPIIO_CMBAT_GET_BIF	 ACPIIO_BATT_GET_BIF
102143771Snjl#define ACPIIO_CMBAT_GET_BST	 ACPIIO_BATT_GET_BST
10378662Siwasaki
104142753Snjl/* Get AC adapter status. */
105119529Snjl#define ACPIIO_ACAD_GET_STATUS	  _IOR('A', 1, int)
10670340Siwasaki
10769744Smsmith#ifdef _KERNEL
108119529Snjltypedef int	(*acpi_ioctl_fn)(u_long cmd, caddr_t addr, void *arg);
109119529Snjlextern int	acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg);
110119529Snjlextern void	acpi_deregister_ioctl(u_long cmd, acpi_ioctl_fn fn);
11169744Smsmith#endif
112142753Snjl
113142753Snjl#endif /* !_ACPIIO_H_ */
114