source: trunk/doc/html/emb-framebuffer-howto.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 7.9 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/framebuffer-howto.doc:36 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Enabling the Linux Framebuffer</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Enabling the Linux Framebuffer</h1>
33
34
35
36<p> This is only a short guide.
37See <a href="file:/usr/src/linux/README">/usr/src/linux/README</a> and
38<a href="file:/usr/src/linux/Documentation/fb/">/usr/src/linux/Documentation/fb/</a> for detailed information.
39There is also a detailed explanation at
40<a href="http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html">http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html</a>.
41<p> <ol type=1>
42<li> Make sure that you have the Linux kernel source code in
43<a href="file:/usr/src/linux/">/usr/src/linux/</a>.
44<p> <li> Log in as root and <tt>cd</tt> <tt>/usr/src/linux</tt>
45<p> <li> Configure the kernel:
46<p> Run:
47<pre>
48 make menuconfig
49</pre>
50
51<p> Select "Code maturity level options" and set "Prompt for
52development and/or incomplete code/drivers".
53<p> Then select "Console drivers" and set "Support for frame buffer
54devices" to built-in (even if it says EXPERIMENTAL). Then configure
55the driver. Most modern graphics cards can use the "VESA VGA
56graphics console"; use that or a driver that specifically matches
57your video card. Finally, enable "Advanced low level driver options"
58and make sure that 16 and 32 bpp packed pixel support are enabled.
59<p> When you are finished, chose exit and save.
60<p> <li> Compile the kernel
61<p> First do:
62<pre>
63 make dep
64</pre>
65
66then:
67<pre>
68 make bzImage
69</pre>
70
71<p> The new kernel should now be in arch/i386/boot/bzImage.
72<p> <li> Copy the kernel to the boot directory:
73<pre>
74 cp arch/i386/boot/bzImage /boot/linux.vesafb
75</pre>
76
77<p> <li> Edit /etc/lilo.conf.
78<p> <b>Warning:</b> Keep a backup of <a href="file:/etc/lilo.conf">/etc/lilo.conf</a>, and have a rescue disk
79available. If you make a mistake, the machine may not boot.
80<p> The file <a href="file:/etc/lilo.conf">/etc/lilo.conf</a> specifies how the system boots. The
81precise contents of the file varies from system to system. Here is
82an example:
83<pre>
84# LILO configuration file
85boot = /dev/hda3
86delay = 30
87image = /boot/vmlinuz
88 root = /dev/hda3
89 label = Linux
90 read-only # Non-UMSDOS filesystems should be mounted read-only for checking
91other=/dev/hda1
92 label=nt
93 table=/dev/hda
94</pre>
95
96<p> Make a new "image" section that is a copy of the first one, but with
97<pre>
98 image = /boot/linux.vesafb
99</pre>
100
101and
102<pre>
103 label = Linux-vesafb
104</pre>
105
106Place it just above the first image section.
107<p> Add a line before the image section saying <tt>vga = 791</tt>. (Meaning
1081024x768, 16 bpp.)
109<p> With the above example, lilo.conf would now be:
110<pre>
111# LILO configuration file
112boot = /dev/hda3
113delay = 30
114vga = 791
115image = /boot/linux.vesafb
116 root = /dev/hda3
117 label = Linux-vesafb
118 read-only # Non-UMSDOS filesystems should be mounted read-only for checking
119image = /boot/vmlinuz
120 root = /dev/hda3
121 label = Linux
122 read-only # Non-UMSDOS filesystems should be mounted read-only for checking
123other=/dev/hda1
124 label=nt
125 table=/dev/hda
126</pre>
127
128<p> Do not change any existing lines in the file; just add new ones.
129<p> <li> To make the new changes take effect, run the lilo program:
130<pre>
131 lilo
132</pre>
133
134<p> <li> Reboot the system. You should now see a penguin logo while the
135system is booting.
136(Or more than one on a multi-processor machine.)
137<p> <li> If it does not boot properly with the new kernel, you can boot with
138the old kernel by entering the label of the old image section at
139the LILO prompt. (with the example lilo.conf file, the old label is
140Linux.)
141<p> If that does not work (probably because of an error in lilo.conf),
142boot the machine using your rescue disk, restore <a href="file:/etc/lilo.conf">/etc/lilo.conf</a> from backup and re-run lilo.
143<p> <li> Testing: Here's a short program that opens the frame buffer and draws a
144gradient-filled red square.
145<p> <pre>
146#include &lt;unistd.h&gt;
147#include &lt;stdio.h&gt;
148#include &lt;fcntl.h&gt;
149#include &lt;linux/fb.h&gt;
150#include &lt;sys/mman.h&gt;
151
152int main()
153{
154 int fbfd = 0;
155 struct fb_var_screeninfo vinfo;
156 struct fb_fix_screeninfo finfo;
157 long int screensize = 0;
158 char *fbp = 0;
159 int x = 0, y = 0;
160 long int location = 0;
161
162 // Open the file for reading and writing
163 fbfd = open("/dev/fb0", O_RDWR);
164 if (!fbfd) {
165 printf("Error: cannot open framebuffer device.\n");
166 exit(1);
167 }
168 printf("The framebuffer device was opened successfully.\n");
169
170 // Get fixed screen information
171 if (ioctl(fbfd, FBIOGET_FSCREENINFO, &amp;finfo)) {
172 printf("Error reading fixed information.\n");
173 exit(2);
174 }
175
176 // Get variable screen information
177 if (ioctl(fbfd, FBIOGET_VSCREENINFO, &amp;vinfo)) {
178 printf("Error reading variable information.\n");
179 exit(3);
180 }
181
182 printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );
183
184 // Figure out the size of the screen in bytes
185 screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
186
187 // Map the device to memory
188 fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
189 fbfd, 0);
190 if ((int)fbp == -1) {
191 printf("Error: failed to map framebuffer device to memory.\n");
192 exit(4);
193 }
194 printf("The framebuffer device was mapped to memory successfully.\n");
195
196 x = 100; y = 100; // Where we are going to put the pixel
197
198 // Figure out where in memory to put the pixel
199 for ( y = 100; y &lt; 300; y++ )
200 for ( x = 100; x &lt; 300; x++ ) {
201
202 location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
203 (y+vinfo.yoffset) * finfo.line_length;
204
205 if ( vinfo.bits_per_pixel == 32 ) {
206 *(fbp + location) = 100; // Some blue
207 *(fbp + location + 1) = 15+(x-100)/2; // A little green
208 *(fbp + location + 2) = 200-(y-100)/5; // A lot of red
209 *(fbp + location + 3) = 0; // No transparency
210 } else { //assume 16bpp
211 int b = 10;
212 int g = (x-100)/6; // A little green
213 int r = 31-(y-100)/16; // A lot of red
214 unsigned short int t = r&lt;&lt;11 | g &lt;&lt; 5 | b;
215 *((unsigned short int*)(fbp + location)) = t;
216 }
217
218 }
219 munmap(fbp, screensize);
220 close(fbfd);
221 return 0;
222}
223</pre>
224
225</ol>
226<p>
227<!-- eof -->
228<p><address><hr><div align=center>
229<table width=100% cellspacing=0 border=0><tr>
230<td>Copyright &copy; 2007
231<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
232<td align=right><div align=right>Qt 3.3.8</div>
233</table></div></address></body>
234</html>
Note: See TracBrowser for help on using the repository browser.