r300 driver for ATI radeons on Apple hardware + GNU/Linux

Found this on: http://forums.gentoo.org/viewtopic-t-371472.html

Introduction

I. What do we want to do?

The r300 project at sourceforge ( http://r300.sourceforge.net ) has mananged to provide open-source drivers for newer ATi Radeon. Especially the Radeon (Mobility) 9600 (M10) which is built into the Apple Powerbook ALU.

Although their has been support for 2D acceleration on this hardware for a long time, DRI (direct rendering) has not been supported until now. The r300 project provides drivers to get DRI activated on a basis of open-source drivers, which essentially means a drastic speed-up for most of the OpenGL-based applications.

What we want to do is to get DRI working on a Apple Powerbook.

II. What can I expect?

You can expect a drastic speedup for most of the open-gl based applications (e.g. glxgears runs about 10-times faster - but who wants to watch rotating gears all the time? :-) ).

Tested programs:

  • TuxRacer: performance is ok; some problems with fonts in the menu (and with textures {sillian87})
  • Neverball: performance is good; reflection should be turned off - it does not work
  • OpenGL XScreensaver: performance depends on the screensaver (obviously); some screensavers produce 40% CPU usage, others 90%; run very stable
  • bzFlag: bad performance (a dia-show...)
  • gl117: too slow (silian87)
  • FooBillard works very nicely! (silian87)
  • Trigger gives an error whenn starting a race: r300SetupPixelShader: No valid fragment shader, exiting (silian87)
  • Cube gives an error (silian87)
  • Flightgear works, but it is TOO slow to be playable. (silian87)
  • Supertux with the opengl extension, work better than without, nice! (silian87)
  • CannonSmash has got flashing text on menu, but the game works without problems (silian87)
  • lincity-ng very slow with opengl, playable without opengl (but a bit slow). Game works. (silian87)

Please report programs you have tested!

III. What should I not expect?

The drivers a still very experimental:

  • do not expect them to be stable
  • do not expect them to be fast
  • do not expect them to implement every feature needed by some applications

Also the xorg composite extension is still not supported by this driver and will be deactivatet on start-up of X.

Please do also have a look at the project page of the r300 driver:

http://r300.sourceforge.net

Especially the paragraph:

Quote:

 The source code on this website may damage your hardware.
 It is *UNTESTED* and *BROKEN* !
 Or, at least, some of it is.

Some words on this howto

This howto is essentially a compiled version of all the helpful howtos and documentation on this topic spread all of the web. Find the most important resource in the Appendix at the end of this howto.

0. Lets get started: Prerequisites

Before we get started, please check you have got the following software installed:

  • a Gentoo installation (ok, this is obvious :-) )
  • a >=2.6.11 kernel (I am using a 2.6.12 kernel)
  • the x.org x11 implementation (x11-base/xorg-x11-6.8.99.15) with the USE-flags "insecure-drivers" activated (this version of X is hard-masked!)
  • you need obviously the "~ppc" keyword in /etc/make.conf
  • CVS (we will need to fetch some sources)

You will also need some patience (compiling software takes some time!)

Note: Before you start you should consider to create a backup of your current X installation:

Code:

 quickpkg xorg-x11

1. Compling the DRM kernel modules

Now we will the compile the DRM kernel modules. For this we use the "x11-drm" ebuild.

At first you need to make sure that you have DRM deactivated in your kernel and AGP support enabled. Your "<kernel-dir>/.config" should look like this: Code:

 ...
 CONFIG_AGP=m
 CONFIG_AGP_UNINORTH=m
 # CONFIG_DRM is not set
 ...

If your kernel config differs change it accordingly and reboot your machine with the new kernel.

Before we compile the "x11-drm" package we need to define what kernel modules we want. We can do this by adding the line

Code:

 VIDEO_CARDS="radeon"

to our /etc/make.conf file.

Now emerge x11-drm:

Code:

 # takes a minute or so
 emerge -a x11-drm

2. Fetching the sources

What we need are the mesa-sources and DRM drivers (since 07/22/05 the mesa and the drm drivers of the r300 project have been accepted in the Mesa and DRM CVS trees - so we do not need to fetch the source from the r300-project). For this purpose lets create a directory:

Code:

 mkdir -p /usr/src/r300

Now we need to fetch the up-to-date source trees. Let us start with Mesa:

Code:

 cd /usr/src/r300
 export CVSROOT=":pserver:anonymous@cvs.freedesktop.org:/cvs/mesa"
 # This may take a while ("du -ms Mesa" gives me 41 MB)
 cvs checkout Mesa

Now its time to fetch the DRM sources

Code:

 export CVSROOT=":pserver:anonymous@cvs.freedesktop.org:/cvs/dri"
 # "du -ms drm" gives me 5 MB
 cvs checkout drm

The DRM sources tree also contains the kernel drivers. I used the kernel drivers of the "x11-drm" package which have been working very fine so far.

3. Compiling the DRI drivers for X11

Now we are going to compile the DRI drivers for the X-server. At first change your working directory to the root of the Mesa source tree:

Code:

 cd /usr/src/r300/Mesa

We now have to "make" the "linux-dri" target. But before we can do this we have to tweak the configuration. To do this lets changed to the "configs" subdir:

Code:

 cd configs

This directory contains the target configurations for several platforms and operating systems. You may have recognized the "linux-dri-ppc" target. We could use this, but we won't. We will use the "linux-dri" config file and adapt it. The linux-dri configuration file is a general purpose configuration common for all platforms. Fire up you favourite editor to edit the "linux-dri" file (which is hopefully vi... *flaming* :-) ):

Code:

 # Back the old version!
 cp linux-dri linux-dri.backup
 ${EDITOR} linux-dri

Move to the end of the file. You'll see a line, which looks like this:

Code:

 DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 r300 radeon s3v \
 savage sis tdfx trident unichrome ffb

This are all the available DRI drivers which will be built. We only need two of the targets. So copy the line, comment out the original line and remove all targets "r300" (thats what we are talking about...)

(since recent changes "dri_client" is not needed anymore - thanks to gnomeza for pointing this out!).

Code:

 #DRI_DIRS = i810 i830 i915 mach64 mga r128 r200 r300 radeon s3v \
 #  savage sis tdfx trident unichrome ffb
 DRI_DIRS = r300

Next we need to tell Mesa where the DRM drivers can be found. Do this by adding the line:

Code:

 DRM_SOURCE_PATH = /usr/src/r300/drm

Since we are using a general purpose configuration file, we need to introduce some PPC-specific compiler-flags. We can do this by defining this flags with the "OPT_FLAGS" variable. The following flags worked fine for me:

Code:

 OPT_FLAGS = -O2 -mcpu=7450 -mabi=altivec -maltivec -pipe

Save the changes and exit the editor - we are now ready to compile the DRI modules. To do so change your working directory to the root directory of the Mesa tree:

Code:

 cd /usr/src/r300/Mesa

Lets compile the stuff:

Code:

 # this may take some time (7 minutes and 30 secs on my powerbook 1.0 GHz)
 make linux-dri

This produced some nifty libs:

Code:

 ls /usr/src/r300/Mesa/lib

Can you see the "r300_dri.so" file? Yes? Great! Lets copy the "r300_dri" into the DRI driver directory of X:

Code:

 cp /usr/src/r300/Mesa/lib/r300_dri.so /usr/X11R6/lib/modules/dri

4. Tell X to use the MesaGL library (the Gentoo-way)

Now we need to tell X to use the MesaGL library (have you seen the files in the lib-directory of Mesa?). We now create our own GL-implementation directory for the "eselect opengl"-command (formerly known as "opengl-update"):

Code:

 mkdir -p /usr/lib/opengl/mesa-cvs

We need to create three symlinks. One to the aforementioned mesa libraries, one to the header files of mesa and one to the old extensions of the xorg-x11 implementation (thanks to electroarts):

Code:

 ln -s /usr/src/r300/Mesa/lib /usr/lib/opengl/mesa-cvs/lib
 ln -s /usr/src/r300/Mesa/include /usr/lib/opengl/mesa-cvs/include
 ln -s /usr/lib/opengl/xorg-x11/extensions /usr/lib/opengl/mesa-cvs/extensions

Launch "eselect opengl list". You will recognize that we have a additional implementation now: "mesa-cvs". So lets activate our opengl implementation:

Code:

 eselect opengl set mesa-cvs

If you still use opengl-update (which is deprecated and will likely be replaced in the foreseeable future) you can achieve the same as above with:

Code:

 opengl-update mesa-cvs

5. Configuration

We need to configure two things: Loading the AGP modules on startup and tweaking the xorg.conf file.

To load the AGP modules on startup add the lines:

Code:

 agpgart
 uninorth-agp

To your /etc/modules.autoload.d/kernel-2.6 file.

Note: You should always load the AGP drivers before the radeon drivers! Otherwise AGP won't be available and DRI won't work!

Lets configure X now: Fire up again your editor and open the X configuration file: /etc/X11/xorg.conf

I can show you my "device"-section. You can adapt to your needs it if you want:

Code:

 ...
 Section "Device"
        Identifier  "Card0"
        Driver          "radeon"
        VendorName  "ATI Technologies Inc"
        BoardName   "Unknown Board"
        Option "UseFBDev" "On"
        Option "AGPMode" "4"
        Option "EnablePageFlip" "true"
   # This two lines are needed to prevent fonts from being scrambled
        Option "XaaNoScanlineImageWriteRect"
        Option "XaaNoScanlineCPUToScreenColorExpandFill"
        Screen 0
 EndSection
 ...

You may need to change the "identifier" to fit your configuration!

For the "scrambled fonts" issue have a look at:

http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg24410.html

Next you need to activate DRI in you X configuration by loading the modules "dri" and "drm"

Code:

 Section "Module"
   ...
        Load    "drm"
        Load    "dri"
        ...
 EndSection

And don't forget the famous "dri" section:

Code:

 Section "dri"
        Mode 0666
 EndSection

I also had some permission problems using udev. You should add your user to the "video" group if you experience a similar problem!

6. Testing

Now it time to test our configuration:

Code:

 # Shut down your X-server
 # remove all the loaded video modules (example:)
 rmmod radeon
 rmmod drm
 # load the agp-modules
 modprobe agpgart
 modprobe uninorth-agp
 # launch dmesg and lsmod to see if everything worked fine!
 dmesg
 lsmod
 # start-up the X server again and have a look at /var/log/Xorg.0.log

Your Xorg.0.log should look like mine (the relevant parts):

Code:

 ...
 (WW) RADEON(0): Enabling DRM support
   *** Direct rendering support is highly experimental for Radeon 9500
   *** and newer cards. In fact, the only thing you could probably use
   ***  it for is better 2d acceleration. The 3d mesa driver is not 
   *** provided in this tree. A very experimental (and incomplete)
   *** version is available from http://r300.sourceforge.net
   *** This message has been last modified on 12/12/04.
 drmOpenDevice: node name is /dev/dri/card0
 drmOpenDevice: open result is -1, (No such device or address)
 drmOpenDevice: open result is -1, (No such device or address)
 drmOpenDevice: Open failed
 drmOpenDevice: node name is /dev/dri/card0
 drmOpenDevice: open result is -1, (No such device or address)
 drmOpenDevice: open result is -1, (No such device or address)
 drmOpenDevice: Open failed
 drmOpenByBusid: Searching for BusID pci:0000:00:10.0
 drmOpenDevice: node name is /dev/dri/card0
 drmOpenDevice: open result is 7, (OK)
 drmOpenByBusid: drmOpenMinor returns 7
 drmOpenByBusid: drmGetBusid reports pci:0000:00:10.0
 (II) RADEON(0): drm loaded kernel module for "radeon" driver
 (II) RADEON(0): drm DRM interface version 1.2
 (II) RADEON(0): drm created "radeon" driver at busid "pci:0000:00:10.0"
 (II) RADEON(0): drm added 8192 byte SAREA at 0xe100d000
 (II) RADEON(0): drm mapped SAREA 0xe100d000 to 0x340b9000
 (II) RADEON(0): drm framebuffer handle = 0xb8000000
 (II) RADEON(0): drm added 1 reserved context for kernel
 (II) RADEON(0): agp Mode 0x07000207 AGP 0x106b/0x0034; Card 0x1002/0x4e50
 (II) RADEON(0): agp 8192 kB allocated with handle 0x00000001
 (II) RADEON(0): agp ring handle = 0x00000000
 (II) RADEON(0): agp Ring mapped at 0x340bb000
 (II) RADEON(0): agp ring read ptr handle = 0x00101000
 (II) RADEON(0): agp Ring read ptr mapped at 0x341bc000
 (II) RADEON(0): agp vertex/indirect buffers handle = 0x00102000
 (II) RADEON(0): agp Vertex/indirect buffers mapped at 0x341bd000
 (II) RADEON(0): agp GART texture map handle = 0x00302000
 (II) RADEON(0): agp GART Texture map mapped at 0x343bd000
 (II) RADEON(0): drm register handle = 0xb0000000
 (II) RADEON(0): dri Visual configs initialized
 (II) RADEON(0): Depth moves disabled by default
 (II) RADEON(0): CP in BM mode
 (II) RADEON(0): Using 8 MB GART aperture
 (II) RADEON(0): Using 1 MB for the ring buffer
 (II) RADEON(0): Using 2 MB for vertex/indirect buffers
 (II) RADEON(0): Using 5 MB for GART textures
 (II) RADEON(0): Memory manager initialized to (0,0) (1280,8191)
 (II) RADEON(0): Reserved area from (0,854) to (1280,856)
 (II) RADEON(0): Largest offscreen area available: 1280 x 7335
 (II) RADEON(0): Will use back buffer at offset 0x119c000
 (II) RADEON(0): Will use depth buffer at offset 0x15c8000
 (II) RADEON(0): Will use 38912 kb for textures at offset 0x1a00000
 (II) RADEON(0): Render acceleration unsupported on Radeon 9500/9700 and newer.
 (II) RADEON(0): Render acceleration disabled
 (**) RADEON(0): Option "XaaNoScanlineCPUToScreenColorExpandFill"
 (**) RADEON(0): Option "XaaNoScanlineImageWriteRect"
 (II) RADEON(0): Using XFree86 Acceleration Architecture (XAA)
    Screen to screen bit blits
    Solid filled rectangles
    8x8 mono pattern filled rectangles
    Solid Lines
    Offscreen Pixmaps
    Setting up tile and stipple cache:
       32 128x128 slots
       32 256x256 slots
       16 512x512 slots
 (II) RADEON(0): Acceleration enabled
 (==) RADEON(0): Backing store disabled
 (==) RADEON(0): Silken mouse enabled
 (II) RADEON(0): Using hardware cursor (scanline 856)
 (II) RADEON(0): Largest offscreen area available: 1280 x 7331
 (II) RADEON(0): No video input capabilities detected and no information is    provided - disabling multimedia i2c
 (II) RADEON(0): no multimedia table present, disabling Rage Theatre.
 (II) RADEON(0): X context handle = 0x1
 (II) RADEON(0): drm installed DRM signal handler
 (II) RADEON(0): DRI installation complete
 (II) RADEON(0): drm Added 32 65536 byte vertex/indirect buffers
 (II) RADEON(0): drm Mapped 32 vertex/indirect buffers
 (II) RADEON(0): drm dma control initialized, using IRQ 48
 (II) RADEON(0): drm Initialized kernel GART heap manager, 5111808
 (II) RADEON(0): Direct rendering enabled
 ...

Now launch a shell in X and type

Code:

 env LIBGL_DEBUG=verbose glxinfo

And look for the magic line

Code:

 direct rendering = yes

If it says "no" have a look at the debugging output procduced by the "LIBGL_DEBUG=verbose" variable and post it here in the forums!

7. Updating the drivers

(Thanks to scoobydu for pointing out that this is missing)

In order to update the drivers you need to update the two CVS repositories. Before we update the Mesa repository we should make a copy of our own "linux-dri" file:

Code:

 # lets backup our linux-dri file
 cp /usr/src/r300/Mesa/configs/linux-dri /usr/src/r300/Mesa/configs/my-linux-dri

You should also update the old binaries in order to avoid problems if the new binaries are causing problems (thanks againg to scoobydu):

Code:

 cp -r /usr/src/r300/Mesa/lib /usr/src/r300/Mesa/lib-backup

Now we can update the repository:

Code:

 # change working directory to root of Mesa CVS
 cd /usr/src/r300/Mesa
 # lets update the CVS repository
 cvs update -dP
 # CVS will report some conflicts. Something like this:
 #   Merging differences between 1.33 and 1.34 into linux-dri
 #   rcsmerge: warning: conflicts during merge
 #   cvs update: conflicts found in configs/linux-dri

You can remove the conflicts from the file manually or restore our copy of the modified linux-dri file:

Code:

 mv /usr/src/r300/Mesa/configs/my-linux-dri /usr/src/r300/Mesa/configs/linux-dri

The same procedure with the drm repository:

Code:

 cd /usr/src/r300/drm
 cvs update -dP

Watch the CVS output to find out whether relevant files have been changed since the last update or not ('man cvs')! Now re-compile the sources:

Code:

 cd /usr/src/r300/Mesa
 # make will only re-compile the modified stuff!
 make linux-dri

Now copy the r300_dri.so file into the X directory and update the environment:

Code:

 cp lib/r300_dri.so /usr/X11R6/lib/modules/dri/
 env-update

Now just follow the steps of "6. Testing"

Page generated by UWiKiCMS 1.1.8 on Thu Nov 21 2024.
Copyright © 2009 Christian Mauduit. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
Updated on Tue Oct 06 2009.