我如何解决 Toshiba Linux 背光问题

症状:

我已经拥有 Toshiba Z830 和 R850 几年了。在两者上,我都使用当前 LTS 版本的 KUbuntu(撰写本文时为 14.04)。虽然我对它们绝对满意,但背光有一个小问题:

启动时,背光工作完美。我可以使用 FN+F6/F7 更改设置而没有任何问题。然而,在将设备置于待机状态并再次唤醒后,按上述热键会显示背光百分比对话框,但不会更改亮度。

因为 Ubuntu 的 SSD 重启相当快,所以过去几年我根本不在意这个问题。然而,出于好奇,我今天成功修复了这个问题。

关于大多数背光问题的根本原因:

一旦我浏览了论坛,我注意到虽然此问题与 toshiba_acpi 驱动程序有关,但其他笔记本品牌(如 Thinkpad)也会出现类似问题。

Linux/Xorg 组合支持多个屏幕,因此需要支持多个背光设备驱动程序同时活动。

可以使用 sysfs 显示当前活动的驱动程序,如下所示:

ls_backlight.sh
uli@uli-z830 ~ % ls /sys/class/backlight
intel_backlight  toshiba

现在的问题是,处理 FN+F6/F7 输入的软件(最终它们似乎被重定向到 XRandR)本身不知道设置背光的正确设备。

Debian 邮件列表中所讨论的,在 Xorg 中选择正确的背光驱动程序有一个相当简单的规则集。

当无法使用热键更改我的 Toshiba 硬件的背光时,可以使用以下命令设置屏幕亮度(需要 root 权限!)

set_backlight_brightness.sh
root@uli-z830 ~ # echo 2000 > /sys/class/backlight/intel_backlight/brightness

2000 — 在这种情况下 — 是中等亮度的值。有效值范围是特定于驱动程序的,但最小值始终为 0,而最大值始终是 /sys/class/backlight/intel_backlight/max_brightness 中列出的值(当然,如果你打算更改不同背景驱动程序的亮度,可能需要将 intel_backlight 替换为你的驱动程序名称)。

对于 Toshiba 笔记本,处理热键的软件的规则集将 acpi_video0toshiba(参见下文了解两者之间的区别)识别为默认值。然而,intel_backlight 才是正确的选择。

虽然 Debian 邮件列表上的人讨论了在哪里解决此问题,但对于 KUbuntu 1.40 和原始(自编译)3.16-rc5 内核,它不能开箱即用。

默认情况下(即在全新安装上)似乎只有 acpi_video 背光驱动程序。如果我遵循论坛上的众多建议或 LinLap.com 的 Z830 页面并将 acpi_backlight=vendor 添加到 GRUB2 启动命令行(你可以使用 cat /proc/cmdline 验证它是否有效),仅此一项不起作用。

因此核心问题是:我在哪里可以将默认背光驱动程序更改为使用 intel_backlight

解决问题:

步骤 1:修复 GRUB2 命令行

编辑: 此步骤不是严格必要的,但建议执行。

虽然我不确定这是否是解决根本问题的严格必要条件,但我建议按照 LinLap.com 上的建议更改 GRUB2 命令行。

目前,我使用以下 GRUB2 配置(仅显示更改的行):

grub_cmdline_example.sh
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop acpi_osi=Linux acpi_backlight=vendor pcie_aspm=force i915.i915_enable_rc6=1 i915.lvds_downclock=1"

elevator=noop 更改默认 IO 调度程序,其他选项处理 ACPI 背光内容并(根据 LinLap.com)增加 Z830 电池寿命。我没有尝试验证电池寿命是否改善,因为我在 Linux 上已经有出色的电池寿命。

步骤 2:创建 xorg.conf

即使它们可能对其他人有用,LinLap.com 上建议的关于 /etc/pm/sleep.d/restore_brightness 的修复对我来说不起作用。

优秀的 ArchLinux 背光 wiki 页面建议在 /etc/X11/xorg.conf 中设置 Backlight 选项。然而,此文件在最近的 Ubuntu 版本中不存在。如果你的 Linux 发行版中存在此文件,可以跳过此步骤。

首先,你需要以 root 身份登录到不在 X11 内运行的控制台(例如使用 Ctrl+Alt+F1)。停止 X11 后(我假设你使用 kdm 作为显示管理器 — 如果不是,只需将其替换为例如 lightdm),我们将在 /root 中创建 xorg.conf.new 然后将其移动到 /etc/X11/xorg.conf

create_xorg.sh
uli@uli-z830 ~ # X -configure #Creates /root/xorg.conf.new
uli@uli-z830 ~ # mv /root/xorg.conf.new /etc/X11/xorg.conf

如果这以任何方式破坏了你的显示管理器(即 service kdm start 不起作用),只需删除 /etc/X11/xorg.conf

步骤 3:修改 /etc/xorg.conf

ArchLinux wikiDebian 邮件列表中所建议的,我们现在需要添加一个背光选项。

使用你喜欢的编辑器打开 /etc/X11/xorg.conf 并找到 Device 部分。

在该部分中查找 Driver 子句。将其更改为

xorg.conf
Driver      "intel"

在某些情况下,它可能已经是 intel,但对于我的 Z830 笔记本它是 modeswitch。如果不使用 modeswitch 作为驱动程序,我们将添加的 Backlight 选项将不被识别。然而在我的 R850 上,intel 已经设置。

之后你需要添加背光选项行:

xorg_backlight_option.conf
Option "Backlight" "intel_backlight"

此行在驱动程序部分内的位置并不重要 — 我将它直接放在 Identifier 行上方。

做完这些后,你只需要重启显示管理器(例如 service kdm start)(或者如果你懒的话直接重启)。这应该能解决所有背光问题。

除了使我能够在从待机唤醒后使用背光控制热键外,我现在不仅有 7 种不同的背光设置,还有 10 种(可使用热键选择)或超过 4000 种(可通过向 /sys/class/backlight/intel_backlight/brightness 写入值来选择)。

这是我的 Z830 笔记本的完整可用 /etc/X11/xorg.conf 供进一步参考:

xorg.conf
Section "ServerLayout"
        Identifier     "X.org Configured"
        Screen      0  "Screen0" 0 0
        InputDevice    "Mouse0" "CorePointer"
        InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
        ModulePath   "/usr/lib/xorg/modules"
        FontPath     "/usr/share/fonts/X11/misc"
        FontPath     "/usr/share/fonts/X11/cyrillic"
        FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
        FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
        FontPath     "/usr/share/fonts/X11/Type1"
        FontPath     "/usr/share/fonts/X11/100dpi"
        FontPath     "/usr/share/fonts/X11/75dpi"
        FontPath     "built-ins"
EndSection

Section "Module"
        Load  "glx"
EndSection

Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "kbd"
EndSection

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "auto"
        Option      "Device" "/dev/input/mice"
        Option      "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "Monitor Vendor"
        ModelName    "Monitor Model"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "SWcursor"                  # [<bool>]
        #Option     "kmsdev"                    # <str>
        #Option     "ShadowFB"                  # [<bool>]
        Option "Backlight" "intel_backlight"
        Identifier  "Card0"
        Driver      "intel"
        BusID       "PCI:0:2:0"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        SubSection "Display"
                Viewport   0 0
                Depth     1
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     4
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     8
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     15
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     16
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     24
        EndSubSection
EndSection

Check out similar posts by category: Linux