blob: e941b1679ed78c7349242d97ca763dcca1b39e92 [file] [log] [blame]
caner5047a8a2008-02-14 09:33:05 -07001<html><head><title>Mesa fbdev/DRI Environment</title>
Brian Paul56e9efa2003-09-03 23:04:02 +00002
caner5047a8a2008-02-14 09:33:05 -07003
Brian Paul56e9efa2003-09-03 23:04:02 +00004
Brian Paul36da0452005-01-20 03:55:10 +00005<link rel="stylesheet" type="text/css" href="mesa.css"></head>
6
caner5047a8a2008-02-14 09:33:05 -07007<body>
Brian Paul56e9efa2003-09-03 23:04:02 +00008
caner5047a8a2008-02-14 09:33:05 -07009<center><h1>Mesa fbdev/DRI Drivers</h1></center>
10<br>
Brian Paul56e9efa2003-09-03 23:04:02 +000011
caner5047a8a2008-02-14 09:33:05 -070012<h1>1. Introduction</h1>
Brian Paul56e9efa2003-09-03 23:04:02 +000013
14<p>
Briane75fbd32007-05-04 18:26:41 -060015The fbdev/DRI environment supports hardware-accelerated 3D rendering without
16the X window system. This is typically used for embedded applications.
Brian Paul56e9efa2003-09-03 23:04:02 +000017</p>
18
19<p>
Briane75fbd32007-05-04 18:26:41 -060020Contributors to this project include Jon Smirl, Keith Whitwell and Dave Airlie.
Brian Paul56e9efa2003-09-03 23:04:02 +000021</p>
22
23<p>
Briane75fbd32007-05-04 18:26:41 -060024Applications in the fbdev/DRI environment use
caner5047a8a2008-02-14 09:33:05 -070025the <a href="http://www.nabble.com/file/p15480666/MiniGXL.html"> MiniGLX</a> interface to choose pixel
Briane75fbd32007-05-04 18:26:41 -060026formats, create rendering contexts, etc. It's a subset of the GLX and
27Xlib interfaces allowing some degree of application portability between
28the X and X-less environments.
Brian Paul56e9efa2003-09-03 23:04:02 +000029</p>
30
Brianf2d9a072007-09-27 10:35:37 -060031<p>
caner5047a8a2008-02-14 09:33:05 -070032Note that this environment is not well-supported and these instructions
33may not be completely up to date.
Brianf2d9a072007-09-27 10:35:37 -060034</p>
caner5047a8a2008-02-14 09:33:05 -070035<br>
Brianf2d9a072007-09-27 10:35:37 -060036
Brian27028fc2007-11-27 10:31:05 -070037
Brian Paul56e9efa2003-09-03 23:04:02 +000038
39<h1>2. Compilation</h1>
Brian Paul56e9efa2003-09-03 23:04:02 +000040<p>
caner5047a8a2008-02-14 09:33:05 -070041
42<h2>2.1 glxproto</h2>
43
44Get <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.
Brian Paul4a54ace2004-05-20 22:27:59 +000045</p>
caner5047a8a2008-02-14 09:33:05 -070046
47<h2>2.2 libpciaccess</h2>
48<p>
49Check if you have libpciaccess installed:
50</p>
51
52<pre>pkg-config --modversion pciaccess
53</pre>
54<p>
55If 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>
60Run autogen.sh to generate a configure file. autogen.sh uses autoconf
61utility. This utility may not be installed with your linux distro,
62check if it is available. if not you can use your package manager or
63type:
64</p>
65<pre>sudo apt-get install autoconf
66</pre>
67The next step is to install the libpciaccess library.
68<pre>make
69make install
70</pre>
71<p> Now your libpciaccess.a file is saved into /usr/local/lib
72directory. If you have a libpciaccess.a in /usr/lib you may simply copy
73and 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/.
75Or you may use the following system variables:
76</p>
77<pre>export LD_LIBRARY_PATH=/usr/local/lib
78export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Brian Paul4a54ace2004-05-20 22:27:59 +000079</pre>
80
caner5047a8a2008-02-14 09:33:05 -070081<h2>2.3 drm</h2>
82
83<p>The next step is to compile the drm. DRM consists of two seperate parts,
84the DRM client library(lindrm.so) and kernel device module(such as
85radeon.ko). We need to make a small change in kernel device module. So
86you need to download the kernel source. You may choose the nearest
87mirror from www.kernel.org, or you are using Fedora Core 5, for
88example, you may need to install RPMs such as:
89kernel-smp-devel-2.16.15-1.2054_FC5.i686.rpm
90kernel-devel-2.6.15-1.2054_FC5.i686.rpm
91etc. You can find a detailed information <a href="http://www.howtoforge.com/kernel_compilation_fedora">here.</a>
Brian62ef0012007-05-09 08:17:57 -060092</p>
caner5047a8a2008-02-14 09:33:05 -070093
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
Brian62ef0012007-05-09 08:17:57 -060097<pre>
caner5047a8a2008-02-14 09:33:05 -070098 /* ||
99 ((ioctl-&gt;flags &amp; DRM_MASTER) &amp;&amp; !priv-&gt;master)*/
Brian62ef0012007-05-09 08:17:57 -0600100</pre>
caner5047a8a2008-02-14 09:33:05 -0700101Now you are ready to compile your kernel. If your kernel version is
102identical to the version you have compiled, you can simply over write
103your new "ko" files over older ones. If you have compiled a different
104kernel, you must configure your grub or lilo to be able to boot your
105new kernel. <p>
Briane75fbd32007-05-04 18:26:41 -0600106You'll need fbdev header files. Check with:
Brian Paul4a54ace2004-05-20 22:27:59 +0000107</p>
108<pre>
caner5047a8a2008-02-14 09:33:05 -0700109 ls -l /usr/include/linux/fb.
Brian Paul4a54ace2004-05-20 22:27:59 +0000110</pre>
caner5047a8a2008-02-14 09:33:05 -0700111<p>This file may be missing if you have not installed linux header files.
Brian Paul4a54ace2004-05-20 22:27:59 +0000112
caner5047a8a2008-02-14 09:33:05 -0700113
114<h2>2.4 Mesa</h2>
115
116</p><p>Get latest development Mesa sources from git repository
117(currently 7.1-prerelease)
Brian Paul56e9efa2003-09-03 23:04:02 +0000118</p>
119<pre>
caner5047a8a2008-02-14 09:33:05 -0700120 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
124to build your linux-solo. You probably wont have this utility. You can
125download 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.
136You 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
140graphics driver you need, delete the unwanted drivers names from the
141list(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 }
Brian Paul56e9efa2003-09-03 23:04:02 +0000150</pre>
151
152<p>
Briane75fbd32007-05-04 18:26:41 -0600153When complete you should have the following:
Brian Paulf4b909b2004-04-18 20:17:14 +0000154</p>
Brian Paul56e9efa2003-09-03 23:04:02 +0000155<ul>
Briane75fbd32007-05-04 18:26:41 -0600156<li>lib/libGL.so - the GL library which applications link with
caner5047a8a2008-02-14 09:33:05 -0700157</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>
Brian Paul56e9efa2003-09-03 23:04:02 +0000161
caner5047a8a2008-02-14 09:33:05 -0700162To install these files into appropriate locations in system:
163<pre>
164 make install
165</pre>
166
167Now your openGL libraries are copied to /usr/local/lib and
168miniglx.conf is copied to /etc. You may copy them to /usr/lib and
169overwrite 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>
Brian Paul56e9efa2003-09-03 23:04:02 +0000175
Briane75fbd32007-05-04 18:26:41 -0600176
Brian Paul56e9efa2003-09-03 23:04:02 +0000177<h1>3. Using fbdev/DRI</h1>
178
179<p>
Briane75fbd32007-05-04 18:26:41 -0600180If an X server currently running, exit/stop it so you're working from
caner5047a8a2008-02-14 09:33:05 -0700181the console. Following command shuts down the x window and also the multi user support.
Brian Paul56e9efa2003-09-03 23:04:02 +0000182</p>
caner5047a8a2008-02-14 09:33:05 -0700183<pre>
184 init 1
185</pre>
Brian Paul56e9efa2003-09-03 23:04:02 +0000186
caner5047a8a2008-02-14 09:33:05 -0700187<p>Also you may define the runlevel as 1 in "/etc/inittab". Your system
188will always start in single user mode and without x-window with this
189option set.
190</p><h2>3.1 Load Kernel Modules</h2>
Brian Paul56e9efa2003-09-03 23:04:02 +0000191
192<p>
Brian Paul4a54ace2004-05-20 22:27:59 +0000193You'll need to load the kernel modules specific to your graphics hardware.
194Typically, this consists of the agpgart module, an fbdev driver module
Briane75fbd32007-05-04 18:26:41 -0600195and the DRM kernel module.
196</p>
197<p>
198As root, the kernel modules can be loaded as follows:
Brian Paul56e9efa2003-09-03 23:04:02 +0000199</p>
200
Briane75fbd32007-05-04 18:26:41 -0600201<p>
202If you have Intel i915/i945 hardware:
203</p>
caner5047a8a2008-02-14 09:33:05 -0700204<pre> modprobe agpgart # the AGP GART module
Briane75fbd32007-05-04 18:26:41 -0600205 modprobe intelfb # the Intel fbdev driver
206 modprobe i915 # the i915/945 DRI kernel module
207</pre>
Brian Paul56e9efa2003-09-03 23:04:02 +0000208
209<p>
Briane75fbd32007-05-04 18:26:41 -0600210If you have ATI Radeon/R200 hardware:
Brian Paul56e9efa2003-09-03 23:04:02 +0000211</p>
caner5047a8a2008-02-14 09:33:05 -0700212<pre> modprobe agpgart # the AGP GART module
Brian Paul56e9efa2003-09-03 23:04:02 +0000213 modprobe radeonfb # the Radeon fbdev driver
214 modprobe radeon # the Radeon DRI kernel module
215</pre>
216
217<p>
Briane75fbd32007-05-04 18:26:41 -0600218If you have ATI Rage 128 hardware:
Brian Paul56e9efa2003-09-03 23:04:02 +0000219</p>
caner5047a8a2008-02-14 09:33:05 -0700220<pre> modprobe agpgart # the AGP GART module
Brian Paul56e9efa2003-09-03 23:04:02 +0000221 modprobe aty128fb # the Rage 128 fbdev driver
222 modprobe r128 # the Rage 128 DRI kernel module
223</pre>
224
225<p>
Briane75fbd32007-05-04 18:26:41 -0600226If you have Matrox G200/G400 hardware:
Brian Paul56e9efa2003-09-03 23:04:02 +0000227</p>
caner5047a8a2008-02-14 09:33:05 -0700228<pre> modprobe agpgart # the AGP GART module
Brian Paul56e9efa2003-09-03 23:04:02 +0000229 modprobe mgafb # the Matrox fbdev driver
230 modprobe mga # the Matrox DRI kernel module
231</pre>
232
233<p>
Briane75fbd32007-05-04 18:26:41 -0600234To verify that the agpgart, fbdev and drm modules are loaded:
Brian Paul56e9efa2003-09-03 23:04:02 +0000235</p>
caner5047a8a2008-02-14 09:33:05 -0700236<pre> ls -l /dev/agpgart /dev/fb* /dev/dri
Brian Paul56e9efa2003-09-03 23:04:02 +0000237</pre>
Briane75fbd32007-05-04 18:26:41 -0600238<p>
239Alternately, use lsmod to inspect the currently installed modules.
240If you have problems, look at the output of dmesg.
241</p>
Brian Paul70dacab2004-02-13 18:29:42 +0000242
Brian Paul56e9efa2003-09-03 23:04:02 +0000243
244<h2>3.2 Configuration File</h2>
245
246<p>
caner5047a8a2008-02-14 09:33:05 -0700247review/edit /etc/miniglx.conf.
Briane75fbd32007-05-04 18:26:41 -0600248Alternately, the MINIGLX_CONF environment variable can be used to
249indicate the location of miniglx.conf
Brian Paul56e9efa2003-09-03 23:04:02 +0000250</p>
251
Briane75fbd32007-05-04 18:26:41 -0600252To determine the pciBusID value, run lspci and examine the output.
253For example:
caner5047a8a2008-02-14 09:33:05 -0700254<p></p>
255<pre> /sbin/lspci:
Briane75fbd32007-05-04 18:26:41 -0600256 00:02.0 VGA compatible controller: Intel Corporation 82915G/GV/910GL Express Chipset Family Graphics Controller (rev 04)
257</pre>
258<p>
25900:02.0 indicates that pciBusID should be PCI:0:2:0
260</p>
261
262
Brian Paul56e9efa2003-09-03 23:04:02 +0000263
264
265<h2>3.3 Running fbdev/DRI Programs</h2>
266
267<p>
268Make sure your LD_LIBRARY_PATH environment variable is set to the
Briane75fbd32007-05-04 18:26:41 -0600269location of the libGL.so library. You may need to append other paths
270to LD_LIBRARY_PATH if libpciaccess.so is in a non-standard location,
271for example.
Brian Paul56e9efa2003-09-03 23:04:02 +0000272</p>
273
274<p>
Brian Paulf4b909b2004-04-18 20:17:14 +0000275Change to the <code>Mesa/progs/miniglx/</code> directory and
Brian Paul56e9efa2003-09-03 23:04:02 +0000276start the sample_server program in the background:
277</p>
caner5047a8a2008-02-14 09:33:05 -0700278<pre> ./sample_server &amp;
Brian Paul56e9efa2003-09-03 23:04:02 +0000279</pre>
280
281<p>
282Then try running the <code>miniglxtest</code> program:
283</p>
caner5047a8a2008-02-14 09:33:05 -0700284<pre> ./miniglxtest
Brian Paul56e9efa2003-09-03 23:04:02 +0000285</pre>
286<p>
287You should see a rotating quadrilateral which changes color as it rotates.
288It will exit automatically after a bit.
289</p>
290
291<p>
292If you run other tests in the miniglx/ directory, you may want to run
293them from a remote shell so that you can stop them with ctrl-C.
294</p>
caner5047a8a2008-02-14 09:33:05 -0700295<br>
Brian Paul56e9efa2003-09-03 23:04:02 +0000296
297
298<h1>4.0 Troubleshooting</h1>
299
Briane75fbd32007-05-04 18:26:41 -0600300<ol>
301<li>
Brian Paul56e9efa2003-09-03 23:04:02 +0000302If you try to run miniglxtest and get the following:
Briane75fbd32007-05-04 18:26:41 -0600303<br>
caner5047a8a2008-02-14 09:33:05 -0700304<pre> [miniglx] failed to probe chipset
Brian Paul56e9efa2003-09-03 23:04:02 +0000305 connect: Connection refused
306 server connection lost
307</pre>
Brian Paul56e9efa2003-09-03 23:04:02 +0000308It means that the sample_server process is not running.
Briane75fbd32007-05-04 18:26:41 -0600309<br>
310<br>
311</li>
Brian91948f92007-05-04 18:32:02 -0600312</ol>
Brian Paul56e9efa2003-09-03 23:04:02 +0000313
314
315<h1>5.0 Programming Information</h1>
316
317<p>
caner5047a8a2008-02-14 09:33:05 -0700318OpenGL/Mesa is interfaced to fbdev via the <a href="http://www.nabble.com/file/p15480666/MiniGLX.html">MiniGLX</a>
Brian Paul56e9efa2003-09-03 23:04:02 +0000319interface.
320MiniGLX is a subset of Xlib and GLX API functions which provides just
321enough functionality to setup OpenGL rendering and respond to simple
322input events.
323</p>
324
325<p>
326Since MiniGLX is a subset of the usual Xlib and GLX APIs, programs written
327to the MiniGLX API can also be run on full Xlib/GLX implementations.
328This allows some degree of flexibility for software development and testing.
329</p>
330
Brian Paule0823482003-09-03 23:10:31 +0000331<p>
332However, the MiniGLX API is not binary-compatible with full Xlib/GLX.
333Some of the structures are different and some macros/functions work
334differently.
335See the <code>GL/miniglx.h</code> header file for details.
336</p>
Brian Paul56e9efa2003-09-03 23:04:02 +0000337
338
caner5047a8a2008-02-14 09:33:05 -0700339
Brian Paul56e9efa2003-09-03 23:04:02 +0000340</body>
341</html>