Xorg 支援大多數常見的顯示卡、鍵盤以及指標裝置。
顯示卡、顯示器以及輸入裝置會自動偵測,無須任何手動設置。除非自動設置失敗,否則請勿建立 xorg.conf
或執行 -configure
步驟。
若 Xorg 曾經在電腦使用過,可先將現有的設定檔重新命名或移除:
#
mv /etc/X11/xorg.conf ~/xorg.conf.etc
#
mv /usr/local/etc/X11/xorg.conf ~/xorg.conf.localetc
加入要執行 Xorg 的使用者到 video
或 wheel
群組,以便在可用時能開啟 3D 加速。要加入使用者 jru
到任一個可用的群組:
#
pw groupmod video -m jru
|| pw groupmod wheel -m jru
預設內含 TWM 視窗管理程式,啟動 Xorg 時便會啟動該視窗管理程式:
%
startx
在部份較舊版的 FreeBSD,在切換回文字 Console 前系統 Console 必須設為 vt(4) 才可正常運作,請參考 節 5.4.3, “核心模式設定 (Kernel Mode Setting, KMS)”。
要存取 /dev/dri
需要允許顯示卡的 3D 加速功能,這通常只需要將要執行 X 的使用者加入 video
或 wheel
群組。此處使用 pw(8) 來將使用者 slurms
加入 video
群組,若沒有 video
則會加入 wheel
群組:
#
pw groupmod video -m slurms
|| pw groupmod wheel -m slurms
當電腦顯示從 Console 切換到高螢幕解析度供 X 使用時,必須設定影像輸出模式。最近版本的 Xorg 使用了核心內部的系統來讓切換模式更有效率。較舊版的 FreeBSD 使用的 sc(4) 並不知到 KMS 系統的存在,這會導致關閉 X 之後即始仍在運作但系統 Console 卻呈現空白。較新版的 vt(4) Console 可避免這個問題。
加入此行到 /boot/loader.conf
來開啟 vt(4):
kern.vty=vt
通常不需要做手動設置,除非自動設置無法運作,否則請不要手動建立設定檔。
Xorg 會查看數個目錄來尋找設定檔,在 FreeBSD 較建議使用 /usr/local/etc/X11/
來存放這些設定檔,使用這個目錄可以幫助將應用程式檔案與作業系統檔案分離。
儲存設定檔在傳統的 /etc/X11/
仍可運作,但並不建議將應用程式檔案與基礎 FreeBSD 檔案混合在一起存放。
Because of changes made in recent versions of FreeBSD, it is now possible to use graphics drivers provided by the Ports framework or as packages. As such, users can use one of the following drivers available from graphics/drm-kmod.
2D and 3D acceleration is supported on most Intel KMS driver graphics cards provided by Intel.
Driver name: i915kms
2D and 3D acceleration is supported on most older Radeon KMS driver graphics cards provided by AMD.
Driver name: radeonkms
2D and 3D acceleration is supported on most newer AMD KMS driver graphics cards provided by AMD.
Driver name: amdgpu
For reference, please see https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units or https://en.wikipedia.org/wiki/List_of_AMD_graphics_processing_units for a list of supported GPUs.
3D 加速在大多數 Intel® 顯示晶片都有支援,最新到 Ivy Bridge (HD Graphics 2500, 4000, 及 P4000) 包含 Iron Lake (HD Graphics) 與 Sandy Bridge (HD Graphics 2000)。
驅動程式名稱:intel
參考文獻請至 https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units。
Radeon 顯示卡支援 2D 及 3D 加速,最新到 HD6000 系列。
驅動程式名稱:radeon
參考文獻請至 https://en.wikipedia.org/wiki/List_of_AMD_graphics_processing_units。
有數個 NVIDIA 驅動程式可於 Port 套件集中的 x11
分類取得,請安裝其中與顯示卡相符的驅動程式。
參考文獻請至 https://en.wikipedia.org/wiki/List_of_Nvidia_graphics_processing_units。
部份筆記型電腦加入了額外繪圖處理單元到那些內建晶片組或處理。Optimus 結合了 Intel® 及 NVIDIA 的硬體,Switchable Graphics 或 Hybrid Graphics 則是結合了 Intel® 或 AMD® 處理器與 AMD® Radeon GPU。
這些混合繪圖系統的實作方式均不同,FreeBSD 的 Xorg 尚無法驅動所有的混合繪圖系統版本。
部份電腦提供了 BIOS 的選項可以關閉其中一個繪圖介面卡或選擇 discrete 模式,可用使用其中一種標準顯示卡驅動程式來驅動。例如,有時關閉 Optimus 系統中的 NVIDIA GPU 是可能讓 Intel® 顯示晶片可用 Intel® 驅動程式驅動。
BIOS 設定會依電腦的型號有所不同,在某些情況下,可以同時開啟兩個 GPU,而在建立的設定檔中的 Device
節只使用主要的 GPU 便能讓系統運作。
較不常見的顯示卡驅動程式可在 Port 套件集的 x11-drivers
目錄找到。
若沒有特定的驅動程式可以支援顯示卡,仍可能可用 x11-drivers/xf86-video-vesa 驅動程式來驅動。該驅動程式可使用 x11/xorg 安裝,也可使用 x11-drivers/xf86-video-vesa 手動安裝。當沒有指定驅動程式時 Xorg 會嘗試使用這個驅動程式來驅動顯示卡。
x11-drivers/xf86-video-scfb 也是不特定顯示卡的驅動程式,可在許多 UEFI 及 ARM® 的電腦上運作。
要在設定檔設定使用 Intel® 驅動程式:
/usr/local/etc/X11/xorg.conf.d/driver-intel.conf
Section "Device"
Identifier "Card0"
Driver "intel"
# BusID "PCI:1:0:0"
EndSection
若有多張顯示卡,可取消註解 BusID
identifier 然後設定為想要的顯示卡,顯示卡的 Bus ID 清單可以使用 pciconf -lv | grep -B3 display
取得。
要在設定檔設定使用 Radeon 驅動程式:
/usr/local/etc/X11/xorg.conf.d/driver-radeon.conf
Section "Device"
Identifier "Card0"
Driver "radeon"
EndSection
要在設定檔設定使用 VESA 驅動程式:
/usr/local/etc/X11/xorg.conf.d/driver-vesa.conf
Section "Device"
Identifier "Card0"
Driver "vesa"
EndSection
要設定 UEFI 或 ARM® 電腦使用 scfb
驅動程式:
scfb
影像驅動程式/usr/local/etc/X11/xorg.conf.d/driver-scfb.conf
Section "Device"
Identifier "Card0"
Driver "scfb"
EndSection
幾乎所有顯示器都支援延伸顯示辨識資料標準 (Extended Display Identification Data, EDID),Xorg 會使用 EDID 與顯示器通訊並偵測支援的解析度與更新頻率,然後選擇最適合的設定組合使用該顯示器。
其他顯示器支援的解析度可透過在設定檔中設定想要的解析度來選擇,或者在 X 伺服器啟動之後使用 xrandr(1)。
執行 xrandr(1) 不加任何參數可檢查影像輸出及已偵測到的顯示器模式清單:
%
xrandr
Screen 0: minimum 320 x 200, current 3000 x 1920, maximum 8192 x 8192
DVI-0 connected primary 1920x1200+1080+0 (normal left inverted right x axis y axis) 495mm x 310mm
1920x1200 59.95*+
1600x1200 60.00
1280x1024 85.02 75.02 60.02
1280x960 60.00
1152x864 75.00
1024x768 85.00 75.08 70.07 60.00
832x624 74.55
800x600 75.00 60.32
640x480 75.00 60.00
720x400 70.08
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
這個結果顯示 DVI-0
輸出被用來顯示解析度為 1920x1200 像素於更新頻率約 60 Hz 的畫面,未有顯示器連接到 DisplayPort-0
與 HDMI-0
接頭。
可使用 xrandr(1) 來選擇任何其他的顯示模式。例如要切換為 1280x1024 於 60 Hz:
%
xrandr --mode 1280x1024 --rate 60
在筆記型電腦使用外部顯示輸出到投影機是常見的作業。
不同裝置間輸出接頭的類型與數量也不同,給每個輸出的名稱在不同驅動程式間也不同。在某些驅動程式稱為 HDMI-1
的輸出在其他驅動程式則可能稱為 HDMI1
。因此第一個步驟是執行 xrandr(1) 列出所有可用的輸出:
%
xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
1366x768 60.04*+
1024x768 60.00
800x600 60.32 56.25
640x480 59.94
VGA1 connected (normal left inverted right x axis y axis)
1280x1024 60.02 + 75.02
1280x960 60.00
1152x864 75.00
1024x768 75.08 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
640x480 75.00 72.81 66.67 60.00
720x400 70.08
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
已找到四個輸出:內建面板的 LVDS1
,外接的 VGA1
, HDMI1
以及 DP1
接頭。
投影機已連接至 VGA1
輸出,現在使用 xrandr(1) 來設定該輸出到投影機 (原始解析度) 並加入額外的空間到桌面的右側:
%
xrandr --output VGA1 --auto --right-of LVDS1
--auto
會選擇使用 EDID 偵測到的解析度與更新頻率。若未正確偵測解析度,可替換 --auto
為 --mode
然後給予固定值。例如大部份的投影機可使用 1024x768 解析度為,則可設定 --mode 1024x768
。
xrandr(1) 通常會在 .xinitrc
執行以在 X 啟動時設定適合的模式。
在設定檔設定螢幕解析度為 1024x768:
/usr/local/etc/X11/xorg.conf.d/screen-resolution.conf
Section "Screen"
Identifier "Screen0"
Device "Card0"
SubSection "Display"
Modes "1024x768"
EndSubSection
EndSection
少數顯示器沒有 EDID,可設定 HorizSync
及 VertRefresh
為顯示器支援的頻率範圍。
/usr/local/etc/X11/xorg.conf.d/monitor0-freq.conf
Section "Monitor"
Identifier "Monitor0"
HorizSync 30-83 # kHz
VertRefresh 50-76 # Hz
EndSection
鍵盤上標準按鍵的位置稱做 配置 (Layout)。配置與其他可調整的參數列於 xkeyboard-config(7)。
預設為 United States 配置,要選擇其他的配置可在 InputClass
設定 XkbLayout
與 XkbVariant
選項。這會套用所有符合該類別的輸入裝置。
這個例子選擇 French 鍵盤配置使用 oss
變體。
/usr/local/etc/X11/xorg.conf.d/keyboard-fr-oss.conf
Section "InputClass"
Identifier "KeyboardDefaults"
Driver "keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "fr"
Option "XkbVariant" "oss"
EndSection
X 可以使用組合鍵來關閉,預設並未設定組合鍵,因為該組合鍵與部份應用程式的鍵盤指令衝突。要開啟這個選項需要更改鍵盤 InputDevice
節:
/usr/local/etc/X11/xorg.conf.d/keyboard-zap.conf
Section "InputClass"
Identifier "KeyboardDefaults"
Driver "keyboard"
MatchIsKeyboard "on"
Option "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection
有許多滑鼠參數可使用設定選項來調整,請參考 mousedrv(4) 來取得完整清單。
在某些情況 Xorg 的自動設定無法在特定硬體上運作,或需要使用不同的設定。針對這些情況會建立自訂的設定檔。
非必要請勿手動建立設定檔,非必要的手動設置會造成運作不正常。
設定檔可由 Xorg 根據偵測到的硬體產生,這個檔案對一開始自訂設定很有幫助。
產生 xorg.conf
:
#
Xorg -configure
設定檔會儲存至 /root/xorg.conf.new
,做任何需要的更改,然後使用以下指令測試該檔案:
#
Xorg -config /root/xorg.conf.new
在新設定檔調整與測試過後,便可分開成較小的檔案放置到正常的位置 /usr/local/etc/X11/xorg.conf.d/
。
本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。
若有 FreeBSD 方面疑問,請先閱讀
FreeBSD 相關文件,如不能解決的話,再洽詢
<questions@FreeBSD.org>。
關於本文件的問題,請洽詢
<doc@FreeBSD.org>。