1.\" $OpenBSD: apm.4,v 1.10 2023/01/30 14:43:29 jcs Exp $ 2.\" 3.\" Copyright (c) 1998 Marco S. Hyman 4.\" 5.\" Permission to copy all or part of this material for any purpose is 6.\" granted provided that the above copyright notice and this paragraph 7.\" are duplicated in all copies. THIS SOFTWARE IS PROVIDED ``AS IS'' 8.\" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT 9.\" LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 10.\" FOR A PARTICULAR PURPOSE. 11.\" 12.Dd $Mdocdate: January 30 2023 $ 13.Dt APM 4 amd64 14.Os 15.Sh NAME 16.Nm apm 17.Nd power management interface 18.Sh SYNOPSIS 19.Cd "acpi0 at mainbus?" 20.Sh DESCRIPTION 21The 22.Nm 23driver provides a user interface to the 24.Xr acpi 4 25driver. 26.Pp 27The 28.Nm 29driver implements the following 30.Xr ioctl 2 31calls. 32They are defined in 33.In machine/apmvar.h . 34.Bl -tag -width Ds 35.It Dv APM_IOC_REJECT 36.Em Not implemented . DO NOT USE . 37.It Dv APM_IOC_STANDBY 38.Pq Li "no parameters" 39Request 40.Dq standby 41mode. 42.It Dv APM_IOC_SUSPEND 43.Pq Li "no parameters" 44Request 45.Dq suspend 46mode. 47.It Dv APM_IOC_HIBERNATE 48.Pq Li "no parameters" 49Request 50.Dq hibernate 51mode. 52.It Dv APM_IOC_GETPOWER 53.Pq Li "struct apm_power_info" 54Request the current power state. 55The argument structure is as follows: 56.Bd -literal -offset indent 57struct apm_power_info { 58 u_char battery_state; 59 u_char ac_state; 60 u_char battery_life; 61 u_char spare1; 62 u_int minutes_left; 63 u_int spare2[6]; 64}; 65.Ed 66.Pp 67The following values are defined for 68.Va battery_state : 69.Bl -tag -width Ds 70.It Dv APM_BATT_HIGH 71Battery has a high state of charge. 72.It Dv APM_BATT_LOW 73Battery has a low state of charge. 74.It Dv APM_BATT_CRITICAL 75Battery has a critical state of charge. 76.It Dv APM_BATT_CHARGING 77Battery is not high, low, or critical and is currently charging. 78.It Dv APM_BATT_UNKNOWN 79Cannot read the current battery state. 80.It Dv APM_BATTERY_ABSENT 81No battery installed. 82.El 83.Pp 84The following values are defined for 85.Va ac_state : 86.Bl -tag -width Ds 87.It Dv APM_AC_OFF 88External power not detected. 89.It Dv APM_AC_ON 90External power detected. 91.It Dv APM_AC_BACKUP 92Backup power in use. 93.It Dv APM_AC_UNKNOWN 94External power state unknown. 95.El 96.Pp 97The 98.Va battery_life 99value contains the estimated percentage of battery life available. 100100% indicates a full charge. 101.Pp 102The 103.Va minutes_left 104value contains the estimated number of minutes of battery life 105remaining. 106.It Dv APM_IOC_DEV_CTL 107.Pq Li "struct apm_ctl" 108Allows an application to directly set the 109APM operating mode. 110The argument structure is as follows: 111.Bd -literal -offset indent 112struct apm_ctl { 113 u_int dev; 114 u_int mode; 115}; 116.Ed 117.Pp 118.Va dev 119indicates the device, typically 120.Dv APM_DEV_ALLDEVS . 121.Pp 122.Va mode 123indicates the desired operating mode. 124Possible values are 125.Bl -tag -width Ds -compact -offset indent 126.It Dv APM_SYS_READY 127.It Dv APM_SYS_STANDBY 128.It Dv APM_SYS_SUSPEND 129.It Dv APM_SYS_OFF 130.It Dv APM_LASTREQ_INPROG 131.It Dv APM_LASTREQ_REJECTED 132.El 133.It Dv APM_IOC_PRN_CTL 134.Pq Li "int" 135This 136.Xr ioctl 2 137controls message output by the APM 138driver when a power change event is detected. 139The integer parameter is one of: 140.Bl -tag -width Ds 141.It Dv APM_PRINT_ON 142All power change events result in a message. 143This is the normal operating mode for the driver. 144.It Dv APM_PRINT_OFF 145Power change event messages are suppressed. 146.It Dv APM_PRINT_PCT 147Power change event messages are suppressed unless the estimated 148battery life percentage changes. 149.El 150.El 151.Sh FILES 152.Bl -tag -width "/dev/apmctlXXX" 153.It /dev/apm 154Power management data device. 155May only be opened read-only. 156May be opened by multiple concurrent users. 157.It /dev/apmctl 158Power management control device. 159May be opened read-write or write-only. 160May only be opened by one user at a time. 161An attempt to open the file when in use will fail, returning 162.Er EBUSY . 163.El 164.Sh SEE ALSO 165.Xr acpi 4 , 166.Xr intro 4 , 167.Xr halt 8 168