1.\" $OpenBSD: apm.4,v 1.8 2019/01/23 22:33:43 jsg 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 23 2019 $ 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_NEXTEVENT 107.Pq Li "struct apm_event_info" 108The APM driver stores up to 109.Dv APM_NEVENTS 110events. 111This was defined as 16 at the time this documentation was written. 112If the event list is full when a new event is detected the new event is lost. 113.Dv APM_IOC_NEXTEVENT 114ioctl returns the next event on the list or 115.Er EAGAIN 116if the event list is empty. 117The format of the returned event is: 118.Bd -literal -offset indent 119struct apm_event_info { 120 u_int type; 121 u_int index; 122 u_int spare[8]; 123}; 124.Ed 125where 126.Va index 127is a sequential count of events that can be used to check if any 128events were lost and 129.Va type 130is one of: 131.Bl -tag -width Ds -offset indent -compact 132.It Dv APM_STANDBY_REQ 133.It Dv APM_SUSPEND_REQ 134.It Dv APM_NORMAL_RESUME 135.It Dv APM_CRIT_RESUME 136.It Dv APM_BATTERY_LOW 137.It Dv APM_POWER_CHANGE 138.It Dv APM_UPDATE_TIME 139.It Dv APM_CRIT_SUSPEND_REQ 140.It Dv APM_USER_STANDBY_REQ 141.It Dv APM_USER_SUSPEND_REQ 142.It Dv APM_SYS_STANDBY_RESUME 143.El 144.It Dv APM_IOC_DEV_CTL 145.Pq Li "struct apm_ctl" 146Allows an application to directly set the 147APM operating mode. 148The argument structure is as follows: 149.Bd -literal -offset indent 150struct apm_ctl { 151 u_int dev; 152 u_int mode; 153}; 154.Ed 155.Pp 156.Va dev 157indicates the device, typically 158.Dv APM_DEV_ALLDEVS . 159.Pp 160.Va mode 161indicates the desired operating mode. 162Possible values are 163.Bl -tag -width Ds -compact -offset indent 164.It Dv APM_SYS_READY 165.It Dv APM_SYS_STANDBY 166.It Dv APM_SYS_SUSPEND 167.It Dv APM_SYS_OFF 168.It Dv APM_LASTREQ_INPROG 169.It Dv APM_LASTREQ_REJECTED 170.El 171.It Dv APM_IOC_PRN_CTL 172.Pq Li "int" 173This 174.Xr ioctl 2 175controls message output by the APM 176driver when a power change event is detected. 177The integer parameter is one of: 178.Bl -tag -width Ds 179.It Dv APM_PRINT_ON 180All power change events result in a message. 181This is the normal operating mode for the driver. 182.It Dv APM_PRINT_OFF 183Power change event messages are suppressed. 184.It Dv APM_PRINT_PCT 185Power change event messages are suppressed unless the estimated 186battery life percentage changes. 187.El 188.El 189.Sh FILES 190.Bl -tag -width "/dev/apmctlXXX" 191.It /dev/apm 192Power management data device. 193May only be opened read-only. 194May be opened by multiple concurrent users. 195.It /dev/apmctl 196Power management control device. 197May be opened read-write or write-only. 198May only be opened by one user at a time. 199An attempt to open the file when in use will fail, returning 200.Er EBUSY . 201.El 202.Sh SEE ALSO 203.Xr acpi 4 , 204.Xr intro 4 , 205.Xr halt 8 206