| ホーム | すべてのクラス | 主要なクラス | 注釈付きクラス一覧 | グループ別クラス | 関数一覧 |
以下は簡単なガイドです。詳しい情報は /usr/src/linux/README と /usr/src/linux/Documentation/fb/ をご覧ください。 http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html にも詳しく説明があります。
以下を実行します :
make menuconfig
"Code maturity level options" を選択し、 "Prompt for development and/or incomplete code/drivers" を設定します。 "Console drivers" を選択し、 "Support for frame buffer devices" を組み込みに設定します (EXPERIMENTAL である場合でも)。 次にドライバを選択します。現在のほとんどのグラフィックカードは "VESA VGA graphics console" を使うことができます。 これを使うか、ビデオカードに適したドライバを使います。 最後に "Advanced low level driver options" を有効にし、 16 bpp と 32 bpp packed pixel support が有効になっていることを確認します。
exit and save を選択して終了します。
以下を実行します :
make dep
次に :
make bzImage
新しいカーネルが arch/i386/boot/bzImage に作成されます。
cp arch/i386/boot/bzImage /boot/linux.vesafb
注意 : /etc/lilo.conf のバックアップを取り、レスキューディスクを作成してください。 ミスをした場合マシンが起動しなくなる場合があります。
/etc/lilo.conf ファイルはシステムがどのように起動するかを指定します。 このファイルの内容はシステムによって異なります。以下は例です :
# LILO configuration file
boot = /dev/hda3
delay = 30
image = /boot/vmlinuz
root = /dev/hda3
label = Linux
read-only # Non-UMSDOS filesystems should be mounted read-only for checking
other=/dev/hda1
label=nt
table=/dev/hda
新しく "image" セクションを作成します。
image = /boot/linux.vesafbそして
label = Linux-vesafb
これを最初の image セクションの上に追加します。
vga = 791. (Meaning
1024x768, 16 bpp.) -->
image セクションの前に vga = 791 (これは 1024x768, 16 bpp を意味します)
という行を追加します。
上の例では、lilo.conf は以下のようになります :
# LILO configuration file
boot = /dev/hda3
delay = 30
vga = 791
image = /boot/linux.vesafb
root = /dev/hda3
label = Linux-vesafb
read-only # Non-UMSDOS filesystems should be mounted read-only for checking
image = /boot/vmlinuz
root = /dev/hda3
label = Linux
read-only # Non-UMSDOS filesystems should be mounted read-only for checking
other=/dev/hda1
label=nt
table=/dev/hda
既存の行は変更しないでください。新しい行を追加するだけです。
lilo
それも上手く動作しない場合 (おそらく lilo.conf にエラーがあるため)、 レスキューディスクを使ってマシンを起動し、 バックアップした /etc/lilo.conf を元に戻して、再び lilo を実行します。
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
int main()
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
// 読み書き用にファイルを開く
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd) {
printf("Error: cannot open framebuffer device.\n");
exit(1);
}
printf("The framebuffer device was opened successfully.\n");
// 固定スクリーン情報を取得
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
printf("Error reading fixed information.\n");
exit(2);
}
// 変動スクリーン情報を取得
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
printf("Error reading variable information.\n");
exit(3);
}
printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );
// バイト単位でのスクリーンのサイズを計算
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
// デバイスをメモリにマップする
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
fbfd, 0);
if ((int)fbp == -1) {
printf("Error: failed to map framebuffer device to memory.\n");
exit(4);
}
printf("The framebuffer device was mapped to memory successfully.\n");
x = 100; y = 100; // ここにピクセルを配置する
// メモリのどこにピクセルを配置するかを計算する
for ( y = 100; y < 300; y++ )
for ( x = 100; x < 300; x++ ) {
location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
(y+vinfo.yoffset) * finfo.line_length;
if ( vinfo.bits_per_pixel == 32 ) {
*(fbp + location) = 100; // Some blue
*(fbp + location + 1) = 15+(x-100)/2; // 緑を少し
*(fbp + location + 2) = 200-(y-100)/5; // 赤をたくさん
*(fbp + location + 3) = 0; // 透明ではない
} else { //assume 16bpp
int b = 10;
int g = (x-100)/6; // 緑を少し
int r = 31-(y-100)/16; // 赤をたくさん
unsigned short int t = r<<11 | g << 5 | b;
*((unsigned short int*)(fbp + location)) = t;
}
}
munmap(fbp, screensize);
close(fbfd);
return 0;
}
| Copyright © 2002 Trolltech | Trademarks | Qt version 3.0.4
|