ACPI/zh-cn
ACPI(Advanced Configuration 和 Power Management Interface)是power management 系统是 BIOS 的一部分。
安装
内核
ACPI 需要开启下列内核选项:
Power management and ACPI options --->
[*] Power Management support
[*] ACPI (Advanced Configuration and Power Interface) Support --->
Option | Module | Recommend | Description |
---|---|---|---|
Deprecated /proc/acpi files | - | No | Creates deprecated files in the procfs filesystem, which are now replaced by files in the sysfs filesystem. |
Deprecated power /proc/acpi directories | - | No | Creates deprecated files in the procfs filesystem, which are now replaced by files in the sysfs filesystem. |
EC read/write access through /sys/kernel/debug/ec | ec-debugfs | No | Debug interface to the Embedded Controller. |
Deprecated /proc/acpi/event support | - | No | Creates deprecated files in the procfs filesystem, which are now replaced by the input layer or netlink events. |
AC Adapter | ac | Laptops | Creates files to tell if your system is connected to AC. |
Battery | battery | Laptops | Creates files to tell if your system is powered by a battery. |
Button | button | - | Handles events on the power, sleep, and lid buttons. |
Video | video | - | Supports basic operations for Video cards. |
Fan | fan | - | Supports ACPI fan devices, allowing user-mode applications to perform basic fan control (on, off, status). |
Dock | dock | - | Supports ACPI-controlled docking stations and removable drive bays, see the acpi dock article. |
Processor | processor | - | Installs ACPI as the idle handler for Linux and uses ACPI C2 and C3 processor states to save power. |
Processor Aggregator | processor-aggregator | - | ACPI 4.0 function to perform specific processor configuration and control. |
Thermal Zone | thermal | Yes | Supports ACPI thermal zones to protect your processor against overheating. |
NUMA support | - | - | |
Debug Statements | - | No | |
PCI slot detection driver | pci-slot | No | Helps to correlate PCI bus addresses with physical slots |
Container and Module Devices | container | - | Supports ACPI Container and Module devices to hotplug nodes, CPUs, and memory. |
Smart Battery System | sbs, sbshc | - | Supports another type of access to battery information, found on some laptops. |
Hardware Error Device | hed | - | Supports the Hardware Error Device, which is used to report some hardware errors. |
Allow ACPI methods to be inserted/replaced at run time | custom-method | No | |
ACPI Platform Error Interface (APEI) | - | - | APEI allows to report errors (for example from the chipset) to the operating system. |
Emerge
桌面环境对 ACPI 生成的常见事件做出反应。如果未安装桌面环境但想让系统对特殊事件做出反应,则可以安装 ACPI 包。安装 sys-power/acpid 包:
root #
emerge --ask sys-power/acpid
USE 标记
Several packages know about the global acpi
USE flag. There are no use flags available for sys-power/acpid at this time.
SELinux
为了让 acpid 能够关闭 SELinux 系统,请确保安装了 sec-policy/selinux-shutdown 包并且重新标记了 /sbin/shutdown 可执行文件:
root #
emerge --ask sec-policy/selinux-shutdown
配置
/etc/acpi 中的脚本定义了系统如何对 ACPI 事件做出反应。它们可以根据需要进行编辑以满足用户的要求。
服务
OpenRC
现在可以启动 acpid 服务。使用 OpenRC 时运行:
root #
/etc/init.d/acpid start
要在系统启动时运行 acpid 服务,请将其添加到默认运行级别:
root #
rc-update add acpid default
systemd
如果 systemd 被用作 init system,使用以下命令在系统启动时开启 acpid 服务:
root #
systemctl enable acpid.service
现在启动服务:
root #
systemctl start acpid.service
进阶示例
默认的 ACPI 设置可能已经能满足一些用户的需求,但为了让 acpid 守护进程正确处理一些基本的 ACPI 事件(如 AC 电源插入/拔出、多媒体键等),可能需要进行一些额外的配置。
如果有必要,可以修改 /etc/acpi/default.sh 和 /etc/acpi/events/default。为什么不创建一个利用 /etc/acpi/actions 和 /etc/acpi/events 功能的复杂设置呢?只需将脚本和事件文件放置在这些位置即可实现高级使用。
对于大多数用户来说一个基本的 default.sh 文件可能就足够了,但是下面是一个使用 default.sh “可以”完成的示例:
#!/bin/sh
#
# $Header: /etc/acpi/default.sh Exp $
# $Author: (c) 2012-2014 -tclover <tokiclover@dotfiles.> Exp $
# $License: MIT (or 2-clause/new/simplified BSD) Exp $
# $Version: 2014/12/24 21:09:26 Exp $
#
log() { logger -p daemon "ACPI: $*"; }
uhd() { log "event unhandled: $*"; }
set $*
group=${1%/*}
action=${1#*/}
device=$2
id=$3
value=$4
[ -d /dev/snd ] && alsa=true || alsa=false
[ -d /dev/oss ] && oss=true || oss=false
amixer="amixer -q set Master"
ossmix="ossmix -- vmix0-outvol"
case $group in
ac_adapter)
case $value in
*0) log "switching to power.bat power profile"
hprofile power.bat;;
*1) log "switching to power.adp power profile"
hprofile power.adp;;
*) uhd $*;;
esac
;;
battery)
case $value in
*0) log "switching to power.adp power profile"
hprofile power.adp;;
*1) log "switching to power.adp power profile"
hprofile power.adp;;
*) uhd $*;;
esac
;;
button)
case $action in
lid)
case "$id" in
close) hibernate-ram;;
open) :;;
*) uhd $*;;
esac
;;
power) shutdown -H now;;
sleep) hibernate-ram;;
mute)
$alsa && $amixer toggle;;
volumeup)
$alsa && $amixer 3dB+
$oss && $ossmix +3;;
volumedown)
$alsa && $amixer 3dB-
$oss && $ossmix -3;;
*) uhd $*;;
esac
;;
cd)
case $action in
play) :;;
stop) :;;
prev) :;;
next) :;;
*) uhd $*;;
esac
;;
jack)
case $id in
*plug) :;;
*) uhd $*;;
esac
;;
video)
case $action in
displayoff) :;;
*) uhd $*;;
esac
;;
*) uhd $*;;
esac
unset alsa oss amixer ossmix group action device id
# vim:fenc=utf-8:ft=sh:ci:pi:sts=4:sw=4:ts=4:
Userspace utilities
许多软件包使用了 ACPI 功能。以下列出了一些:
- sys-power/acpi: to show information from the /proc filesystem, such as battery status or thermal information
- sys-power/acpitool: a small command line application, intended to be a replacement for the apm tool
- sys-power/acpilight: replacement for xbacklight that uses the ACPI interface to set brightness
- app-laptop/laptop-mode-tools: linux kernel laptop_mode user-space utilities
- x11-misc/cbatticon: a lightweight and fast battery icon that sits in your system tray
- app-admin/conky: an advanced, highly configurable system monitor for X
另请参阅
- ACPI/ThinkPad-special-buttons — describes how to configure ACPI events and actions for the Lenovo ThinkPad T410 laptop.
- Suspend and hibernate — describes how to suspend or hibernate a Gentoo system.