灵感的来临,没有任何预兆;灵感的消失,也不会有告别仪式;用文字记下她们吧,让灵感永存……

Linux 下 Intel 8xx 系列显卡旋转屏幕功能解决方案

davies 发表于 2005 年 03 月 24 日

0. 前言

Linux 上常用的 X Window 上有一个扩展协议 RandR ( The X Resize and Rotate Extension),为使用过程中改变屏幕的大小或者旋转角度提供了规范。RandR 需要 X 的显示驱动支持旋转,而 Intel 的 8xx 系列显卡并不具有旋转功能,而通用的 Frame Buffer 驱动支持旋转,可以让它使用 Frame Buffer 的驱动来达到实现屏幕旋转的目的。

这种方案非常简单,但是它没有硬件加速能力,在效率上有一定的损失。

1. 给内核加入FrameBuffer和显卡驱动支持

确保内核中已经有 Frame Buffer 和 Intel 8xx 系列显卡的 fb 驱动支持,如果没有,按下面的步骤加入这些,并重新编译内核。

1.1 配置内核

在kernel的源代码目录运行:make menuconfig,并加入如下选项:

a) 加入开发代码支持:

Code maturity level options
* Prompt for development and/or incomplete code/drivers

b) 加入对 Intel AGP 支持:

Character devices
* /dev/agpgart(AGP Support)
* Intel 440LX/BX… support
* Intel I810… Support

以上二者选其一,根据显卡型号而定,如果不清楚可以都选。

c) 选中 Frame Buffer 支持:

Console drivers
Frame-Buffer support
* Support for frame buffer devices
* Intel 830M/845G/852GM/855GM/865G display support

或者直接修改内核配置文件,编辑该目录下的.config文件,更改以下相关内容:

#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y

#
# Intel AGP Support
#
CONFIG_AGP=y
CONFIG_AGP_INTEL=y

# CONFIG_AGP_I810 #如果是I810/815显卡,则选择此项

#
# Console drivers
#
CONFIG_VIDEO_SELECT=y

#
# Frame-buffer support
#
CONFIG_FB=y
CONFIG_DUMMY_CONSOLE=y
CONFIG_VIDEO_SELECT=y
CONFIG_FB_INTEL=y
CONFIG_FBCON_CFB8=y
CONFIG_FBCON_CFB16=y
CONFIG_FBCON_CFB32=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y

1.2 编译内核,并用新内核启动

make deps
make bzImage
make modules
make modules_install
make install
reboot

2 指定内核启动参数

在内核启动时,通过启动参数可以指定所使用的 Frame-Buffer 驱动以及 Frame-Buffer 所采用的色彩深度,以及显示器的刷新率等。可以通过在 Grub 或者 Lilo 等引导程序的配置文件中加入类似于 video=intelfb:800x600-32@85 的一行来实现。其中intelfb说明使用Intel的Frame-Buffer驱动;800x600为显示分辨率,依显示器而定;32表示32位真彩色(必需),85为显示器的刷新频率,依显示器而定。

2.1 Grub 配置文件修改

Grub 的配置文件(通常为 /boot/grub/grub.conf )中启动 linux 的选项如下:

# For booting GNU/Linux
title Linux
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hda1 ro \ video=intelfb:1024x768-32@85

2.2 lilo 配置文件修改

Lilo 的配置文件(通常为 /etc/lilo.conf )中给内核加启动参数的方式如下:

image=/boot/vmlinuz
label=linux
initrd=initrd.img
root=/dev/hda1
video= intelfb:1024x768-32@85

3. X 的配置

XFree86 从 4.3.0 就开始支持 RandR 了,但支持得并不好,至少需要 XFree86 4.4.0 或者 Xorg 6.8.0,下面以 XFree86 为例。 假设 XFree86 的配置文件(通常为 /etc/X11/XF86Config )在使用自带的 i810 驱动时已经配置完成,能够正常工作,下面对其进行修改,使其能够使用 Frame Buffer 驱动,并实现旋转屏幕的功能。

3.1使用 XFree86 的 Frame Buffer 驱动

在 Device 段,加入如下内容:

Driver “fbdev” #将原先的i810改为fbdev
Option “Rotate” “CW” #CW表示顺时针90度,
#UD表示顺指针180度,倒转
#CCW表示顺时针270度

3.2 设定颜色深度

在 Screen 段,加入如下内容:

DefaultDepth 24 #默认颜色深度,最高24位真彩色
DefaultFbBpp 32 #指明使用Frame Buffer时
#每个像素颜色所用的内存宽度
#在用24位色时,必须指定为32bpp

3.3 一个完整的 XF86Config

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

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
ModulePath "/usr/X11R6/lib/modules"
FontPath "/usr/share/fonts/misc/"
#FontPath "/usr/share/fonts/TTF/"
#FontPath "/usr/share/fonts/Type1/"
#FontPath "/usr/share/fonts/CID/"
FontPath "/usr/share/fonts/75dpi/"
FontPath "/usr/share/fonts/100dpi/"
EndSection

Section "Module"
#Load "record"
#Load "extmod"
#Load "dbe"
#Load "dri"
#Load "glx"
#Load "xtrap"
Load "freetype"
Load "type1"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "keyboard"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/psaux"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "no"
EndSection

Section "Device"
Identifier "Card0"
Driver "fbdev"
#Option "ShadowFB" "off"
Option "Rotate" "CW"
VendorName "Intel Corp."
BoardName "82845G/GL [Brookdale-G] Chipset Integrated Graphics Device"
BusID "PCI:0:2:0"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 24
DefaultFbBpp 32
SubSection "Display"
Modes "1024x768"
EndSubSection
EndSection

Section "Monitor"
Identifier "Monitor0"
Mode "1024x768"
# D: 94.500 MHz, H: 68.677 kHz, V: 84.997 Hz
DotClock 94.501
HTimings 1024 1072 1168 1376
VTimings 768 769 772 808
Flags "+HSync" "+VSync"
EndMode
EndSection

4 效果

下面就是配置旋转屏幕后的 Gnome 桌面

5 后记

这原本是去年寒假时给一个公司的做的小 Project ,由于时间匆忙,只给出了结果,没有把其中的原理讲清楚,事隔几个月后再拿起来,记忆已经开始模糊,也懒得再重新来过了,就这样凑合着看吧 ^_^

网友留言:

我来留言