acpiio.h revision 119529
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 *
2767761Smsmith *	$FreeBSD: head/sys/dev/acpica/acpiio.h 119529 2003-08-28 16:06:30Z njl $
2867761Smsmith */
2967761Smsmith
3069744Smsmith/*
3169744Smsmith * Core ACPI subsystem ioctls
3269744Smsmith */
3367761Smsmith#define ACPIIO_ENABLE		_IO('P', 1)
3467761Smsmith#define ACPIIO_DISABLE		_IO('P', 2)
3567761Smsmith#define ACPIIO_SETSLPSTATE	_IOW('P', 3, int)
3667761Smsmith
3778662Siwasakistruct acpi_battdesc {
38119529Snjl    int	 type;				/* battery type: e.g. CMBAT */
39119529Snjl    int	 phys_unit;			/* physical unit of devclass */
4078662Siwasaki};
4178662Siwasaki
4278662Siwasaki#define ACPI_BATT_TYPE_CMBAT		0x0000
4378662Siwasaki#define ACPI_BATT_TYPE_SMBAT		0x0001
4478662Siwasaki
4578662Siwasakistruct acpi_battinfo {
46119529Snjl    int	 cap;				/* percent */
47119529Snjl    int	 min;				/* remianing time */
48119529Snjl    int	 state;				/* battery state */
4978662Siwasaki};
5078662Siwasaki
5170271Stakawata#define ACPI_CMBAT_MAXSTRLEN 32
5270271Stakawatastruct acpi_bif {
53119529Snjl    u_int32_t unit;			/* 0 for mWh, 1 for mAh */
54119529Snjl    u_int32_t dcap;			/* Design Capacity */
55119529Snjl    u_int32_t lfcap;			/* Last Full capacity */
56119529Snjl    u_int32_t btech;			/* Battery Technorogy */
57119529Snjl    u_int32_t dvol;			/* Design voltage (mV) */
58119529Snjl    u_int32_t wcap;			/* WARN capacity */
59119529Snjl    u_int32_t lcap;			/* Low capacity */
60119529Snjl    u_int32_t gra1;			/* Granulity 1(Warn to Low) */
61119529Snjl    u_int32_t gra2;			/* Granulity 2(Full to Warn) */
62119529Snjl    char model[ACPI_CMBAT_MAXSTRLEN];	/* model identifier */
63119529Snjl    char serial[ACPI_CMBAT_MAXSTRLEN];	/* Serial number */
64119529Snjl    char type[ACPI_CMBAT_MAXSTRLEN];	/* Type */
65119529Snjl    char oeminfo[ACPI_CMBAT_MAXSTRLEN];	/* OEM infomation */
6670271Stakawata};
6770271Stakawata
6870271Stakawatastruct acpi_bst {
69119529Snjl    u_int32_t state;			/* Battery State */
70119529Snjl    u_int32_t rate;			/* Present Rate */
71119529Snjl    u_int32_t cap;			/* Remaining Capacity */
72119529Snjl    u_int32_t volt;			/* Present Voltage */
7370271Stakawata};
7470271Stakawata
7578662Siwasaki#define ACPI_BATT_STAT_DISCHARG		0x0001
7678662Siwasaki#define ACPI_BATT_STAT_CHARGING		0x0002
7778662Siwasaki#define ACPI_BATT_STAT_CRITICAL		0x0004
7878662Siwasaki#define ACPI_BATT_STAT_NOT_PRESENT	0x0007
7978662Siwasaki#define ACPI_BATT_STAT_MAX		0x0007
8078662Siwasaki
8178662Siwasakiunion acpi_battery_ioctl_arg {
82119529Snjl    int	 unit;			/* argument: logical unit (-1 = overall) */
8378662Siwasaki
84119529Snjl    struct acpi_battdesc	battdesc;
85119529Snjl    struct acpi_battinfo	battinfo;
8678662Siwasaki
87119529Snjl    struct acpi_bif	bif;	/* for acpi_cmbat */
88119529Snjl    struct acpi_bst	bst;	/* for acpi_cmbat */
8970340Siwasaki};
9070340Siwasaki
9178662Siwasaki/* Common battery ioctl */
92119529Snjl#define ACPIIO_BATT_GET_UNITS	  _IOR('B', 0x01, int)
93119529Snjl#define ACPIIO_BATT_GET_TYPE	  _IOR('B', 0x02, union acpi_battery_ioctl_arg)
9478662Siwasaki#define ACPIIO_BATT_GET_BATTINFO _IOWR('B', 0x03, union acpi_battery_ioctl_arg)
9578662Siwasaki#define ACPIIO_BATT_GET_BATTDESC _IOWR('B', 0x04, union acpi_battery_ioctl_arg)
9670340Siwasaki
9778662Siwasaki/* Cotrol Method battery ioctl */
98119529Snjl#define ACPIIO_CMBAT_GET_BIF	 _IOWR('B', 0x10, union acpi_battery_ioctl_arg)
99119529Snjl#define ACPIIO_CMBAT_GET_BST	 _IOWR('B', 0x11, union acpi_battery_ioctl_arg)
10078662Siwasaki
101119529Snjl#define ACPIIO_ACAD_GET_STATUS	  _IOR('A', 1, int)
10270340Siwasaki
10369744Smsmith#ifdef _KERNEL
104119529Snjltypedef int	(*acpi_ioctl_fn)(u_long cmd, caddr_t addr, void *arg);
105119529Snjlextern int	acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg);
106119529Snjlextern void	acpi_deregister_ioctl(u_long cmd, acpi_ioctl_fn fn);
10769744Smsmith#endif
108