Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / docs / fbdev-dri.html
1 <html><head><title>Mesa fbdev/DRI Environment</title>
2
3
4
5 <link rel="stylesheet" type="text/css" href="mesa.css"></head>
6
7 <body>
8
9 <center><h1>Mesa fbdev/DRI Drivers</h1></center>
10 <br>
11
12 <h1>1. Introduction</h1>
13
14 <p>
15 The fbdev/DRI environment supports hardware-accelerated 3D rendering without
16 the X window system. This is typically used for embedded applications.
17 </p>
18
19 <p>
20 Contributors to this project include Jon Smirl, Keith Whitwell and Dave Airlie.
21 </p>
22
23 <p>
24 Applications in the fbdev/DRI environment use
25 the <a href="http://www.nabble.com/file/p15480666/MiniGXL.html"> MiniGLX</a> interface to choose pixel
26 formats, create rendering contexts, etc. It's a subset of the GLX and
27 Xlib interfaces allowing some degree of application portability between
28 the X and X-less environments.
29 </p>
30
31 <p>
32 Note that this environment is not well-supported and these instructions
33 may not be completely up to date.
34 </p>
35 <br>
36
37
38
39 <h1>2. Compilation</h1>
40 <p>
41
42 <h2>2.1 glxproto</h2>
43
44 Get <a href="http://cvsweb.xfree86.org/cvsweb/*checkout*/xc/include/GL/glxproto.h?rev=1.9">glxproto.h</a>. Copy it to the /mesa/include/GL/ directory.
45 </p>
46
47 <h2>2.2 libpciaccess</h2>
48 <p>
49 Check if you have libpciaccess installed:
50 </p>
51
52 <pre>pkg-config --modversion pciaccess
53 </pre>
54 <p>
55 If not you can download the latest code from:
56 </p>
57 <pre> git clone git://anongit.freedesktop.org/git/xorg/lib/libpciaccess
58 </pre>
59 <p>
60 Run autogen.sh to generate a configure file. autogen.sh uses autoconf
61 utility. This utility may not be installed with your linux distro,
62 check if it is available. if not you can use your package manager or
63 type:
64 </p>
65 <pre>sudo apt-get install autoconf
66 </pre>
67 The next step is to install the libpciaccess library.
68 <pre>make
69 make install
70 </pre>
71 <p> Now your libpciaccess.a file is saved into /usr/local/lib
72 directory. If you have a libpciaccess.a in /usr/lib you may simply copy
73 and overwrite these files. Don't forget to copy libpciaccess.pc file to
74 /usr/lib/pkgconfig, which is also located in /usr/local/lib/pkgconfig/.
75 Or you may use the following system variables:
76 </p>
77 <pre>export LD_LIBRARY_PATH=/usr/local/lib
78 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
79 </pre>
80
81 <h2>2.3 drm</h2>
82
83 <p>The next step is to compile the drm. DRM consists of two seperate parts,
84 the DRM client library(lindrm.so) and kernel device module(such as
85 radeon.ko). We need to make a small change in kernel device module. So
86 you need to download the kernel source. You may choose the nearest
87 mirror from www.kernel.org, or you are using Fedora Core 5, for
88 example, you may need to install RPMs such as:
89 kernel-smp-devel-2.16.15-1.2054_FC5.i686.rpm
90 kernel-devel-2.6.15-1.2054_FC5.i686.rpm
91 etc. You can find a detailed information <a href="http://www.howtoforge.com/kernel_compilation_fedora">here.</a>
92 </p>
93
94 <p>You will find drm_drv.c at /usr/src/LINUX-VERSION/drivers/char/drm/. Edit this code and comment out the following part:
95 </p>
96
97 <pre>
98 /* ||
99 ((ioctl-&gt;flags &amp; DRM_MASTER) &amp;&amp; !priv-&gt;master)*/
100 </pre>
101 Now you are ready to compile your kernel. If your kernel version is
102 identical to the version you have compiled, you can simply over write
103 your new "ko" files over older ones. If you have compiled a different
104 kernel, you must configure your grub or lilo to be able to boot your
105 new kernel. <p>
106 You'll need fbdev header files. Check with:
107 </p>
108 <pre>
109 ls -l /usr/include/linux/fb.
110 </pre>
111 <p>This file may be missing if you have not installed linux header files.
112
113
114 <h2>2.4 Mesa</h2>
115
116 </p><p>Get latest development Mesa sources from git repository
117 (currently 7.1-prerelease)
118 </p>
119 <pre>
120 git clone git://anongit.freedesktop.org/git/mesa/mesa
121 </pre>
122
123 <p>You will need the makedepend utility which is a part of mesa project
124 to build your linux-solo. You probably wont have this utility. You can
125 download its source from following git repulsitory:
126 </p>
127 <pre>
128 git clone git://anongit.freedesktop.org/git/xorg/util/makedepend
129 </pre>
130
131 <p>Get the latest stable mesa version from SourceForge (currently 7.0.3)
132 <a href="http://sourceforge.net/project/showfiles.php?group_id=3">http://sourceforge.net/project/showfiles.php?group_id=3</a>
133 </p>
134
135 <p>Copy the miniglx folder from 7.1-prerelease to 7.0.3.
136 You may also extract GLUT to 7.0.3 version at this step.
137 </p>
138
139 <p>Edit linux-solo.conf at /conf directory, just only compile the
140 graphics driver you need, delete the unwanted drivers names from the
141 list(some drivers are causing problems...)
142 </p>
143 <pre>
144 while(build==0)
145 {
146 make linux-solo
147
148 There will be some missing header files, copy them from 7.1-prerelease
149 }
150 </pre>
151
152 <p>
153 When complete you should have the following:
154 </p>
155 <ul>
156 <li>lib/libGL.so - the GL library which applications link with
157 </li><li>lib/*_dri_so - DRI drivers
158 </li><li>lib/miniglx.conf - sample MiniGLX config file
159 </li><li>progs/miniglx/* - several MiniGLX sample programs
160 </li></ul>
161
162 To install these files into appropriate locations in system:
163 <pre>
164 make install
165 </pre>
166
167 Now your openGL libraries are copied to /usr/local/lib and
168 miniglx.conf is copied to /etc. You may copy them to /usr/lib and
169 overwrite your old GL libraries. Or you may export following variable:
170
171 <pre>
172 export LIBGL_DRIVERS_PATH=/usr/local/lib
173 </pre>
174 <br>
175
176
177 <h1>3. Using fbdev/DRI</h1>
178
179 <p>
180 If an X server currently running, exit/stop it so you're working from
181 the console. Following command shuts down the x window and also the multi user support.
182 </p>
183 <pre>
184 init 1
185 </pre>
186
187 <p>Also you may define the runlevel as 1 in "/etc/inittab". Your system
188 will always start in single user mode and without x-window with this
189 option set.
190 </p><h2>3.1 Load Kernel Modules</h2>
191
192 <p>
193 You'll need to load the kernel modules specific to your graphics hardware.
194 Typically, this consists of the agpgart module, an fbdev driver module
195 and the DRM kernel module.
196 </p>
197 <p>
198 As root, the kernel modules can be loaded as follows:
199 </p>
200
201 <p>
202 If you have Intel i915/i945 hardware:
203 </p>
204 <pre> modprobe agpgart # the AGP GART module
205 modprobe intelfb # the Intel fbdev driver
206 modprobe i915 # the i915/945 DRI kernel module
207 </pre>
208
209 <p>
210 If you have ATI Radeon/R200 hardware:
211 </p>
212 <pre> modprobe agpgart # the AGP GART module
213 modprobe radeonfb # the Radeon fbdev driver
214 modprobe radeon # the Radeon DRI kernel module
215 </pre>
216
217 <p>
218 If you have ATI Rage 128 hardware:
219 </p>
220 <pre> modprobe agpgart # the AGP GART module
221 modprobe aty128fb # the Rage 128 fbdev driver
222 modprobe r128 # the Rage 128 DRI kernel module
223 </pre>
224
225 <p>
226 If you have Matrox G200/G400 hardware:
227 </p>
228 <pre> modprobe agpgart # the AGP GART module
229 modprobe mgafb # the Matrox fbdev driver
230 modprobe mga # the Matrox DRI kernel module
231 </pre>
232
233 <p>
234 To verify that the agpgart, fbdev and drm modules are loaded:
235 </p>
236 <pre> ls -l /dev/agpgart /dev/fb* /dev/dri
237 </pre>
238 <p>
239 Alternately, use lsmod to inspect the currently installed modules.
240 If you have problems, look at the output of dmesg.
241 </p>
242
243
244 <h2>3.2 Configuration File</h2>
245
246 <p>
247 review/edit /etc/miniglx.conf.
248 Alternately, the MINIGLX_CONF environment variable can be used to
249 indicate the location of miniglx.conf
250 </p>
251
252 To determine the pciBusID value, run lspci and examine the output.
253 For example:
254 <p></p>
255 <pre> /sbin/lspci:
256 00:02.0 VGA compatible controller: Intel Corporation 82915G/GV/910GL Express Chipset Family Graphics Controller (rev 04)
257 </pre>
258 <p>
259 00:02.0 indicates that pciBusID should be PCI:0:2:0
260 </p>
261
262
263
264
265 <h2>3.3 Running fbdev/DRI Programs</h2>
266
267 <p>
268 Make sure your LD_LIBRARY_PATH environment variable is set to the
269 location of the libGL.so library. You may need to append other paths
270 to LD_LIBRARY_PATH if libpciaccess.so is in a non-standard location,
271 for example.
272 </p>
273
274 <p>
275 Change to the <code>Mesa/progs/miniglx/</code> directory and
276 start the sample_server program in the background:
277 </p>
278 <pre> ./sample_server &amp;
279 </pre>
280
281 <p>
282 Then try running the <code>miniglxtest</code> program:
283 </p>
284 <pre> ./miniglxtest
285 </pre>
286 <p>
287 You should see a rotating quadrilateral which changes color as it rotates.
288 It will exit automatically after a bit.
289 </p>
290
291 <p>
292 If you run other tests in the miniglx/ directory, you may want to run
293 them from a remote shell so that you can stop them with ctrl-C.
294 </p>
295 <br>
296
297
298 <h1>4.0 Troubleshooting</h1>
299
300 <ol>
301 <li>
302 If you try to run miniglxtest and get the following:
303 <br>
304 <pre> [miniglx] failed to probe chipset
305 connect: Connection refused
306 server connection lost
307 </pre>
308 It means that the sample_server process is not running.
309 <br>
310 <br>
311 </li>
312 </ol>
313
314
315 <h1>5.0 Programming Information</h1>
316
317 <p>
318 OpenGL/Mesa is interfaced to fbdev via the <a href="http://www.nabble.com/file/p15480666/MiniGLX.html">MiniGLX</a>
319 interface.
320 MiniGLX is a subset of Xlib and GLX API functions which provides just
321 enough functionality to setup OpenGL rendering and respond to simple
322 input events.
323 </p>
324
325 <p>
326 Since MiniGLX is a subset of the usual Xlib and GLX APIs, programs written
327 to the MiniGLX API can also be run on full Xlib/GLX implementations.
328 This allows some degree of flexibility for software development and testing.
329 </p>
330
331 <p>
332 However, the MiniGLX API is not binary-compatible with full Xlib/GLX.
333 Some of the structures are different and some macros/functions work
334 differently.
335 See the <code>GL/miniglx.h</code> header file for details.
336 </p>
337
338
339
340 </body>
341 </html>