Difference between revisions of "Mach64"

From ArchWiki
Jump to: navigation, search
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category: Graphics (English)]]
+
[[Category:Graphics]]
{{Box Note | This article needs to be rewritten because compiling mach64 modules from GIT repository is no longer possible.}}
+
[[Category:X Server]]
 +
[http://en.wikipedia.org/wiki/ATI_Mach#Mach_64 The Mach 64 chip] is an old graphic accelerator developped by ATI. This board has basic 3D capabilites. Its support on Linux is poor but exists. This page is a walkthrough to setup Mach 64 graphics chipsets (including ATI Rage Pro) and obtain direct rendering on some of them.
  
Update: The source is no longer maintained in freedesktop.org's libdrm git repo (git://anongit.freedesktop.org/git/mesa/drm). The people maintaining libdrm who own that repo have deleted the drm kernel modules (like the one this package packages), because these modules are being developed in the kernel's git tree (http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git). However, because mach64 has security issues, it is not in the kernel git tree, however, TryA has uploaded a package by the name of kernel26-mach64 to AUR patched to include these sources.
+
==Installing the basic features==
 +
2D and Xv acceleration in X can be achieved with xf86-video-mach64:
 +
# pacman -S xf86-video-mach64
  
This page is a walk through on obtaining Direct Rendering on a mach64 graphics chipset.
+
==3D acceleration and direct rendering==
If you are looking for the ATI Rage 128, this is not the correct page, however this is the page for the ATI Rage
+
{{Warning | You may experience crashes if using the Mach 64 DRM module. Direct rendering on Mach 64 is not very reliable because it never got much support.}}
Also, if you only want 2D drivers, install just xf86-video-mach64 and skip this.
+
On Linux, the Mach 64 chip uses the DRI/DRM system for direct rendering. The DRI part is available in [community], but the DRM module is not included in the mainline kernel. So we have to build it separately. A package in the [[AUR]] simplifies this task: {{AUR|mach64drm}}.
  
==The Mach 64 Board==
+
As soon as the DRM module is built and installed, make sure you installed the DRI part:
The Mach64 Chip is made by ATI. This page is targeted at the Rage Pro video card (not the Rage 128) which to my knowledge is the only 3D version of the mach64.
+
# pacman -S mach64-dri
[http://en.wikipedia.org/wiki/ATI_Rage Wikipedia: Mach64/Rage Pro]
+
This board has basic 3D capabilites, but Arch's xf86-video-mach64 package does not provide the complete solution. The kernel DRM module is needed, but not included in the kernel. [[#Why Isn't the Mach64 DRM Included In the Kernel?|Why Isn't the Mach64 DRM Included In the Kernel?]]
+
  
Most GNU/Linux 3D graphics drivers use the DRI/DRM system for direct rendering, which is what the Mach64 Driver uses.
+
==Configuration==
 
+
Here is an example of X configuration for a Mach 64 chip (may not be mandatory in all cases):
==Packages and References==
+
[http://dri.freedesktop.org/wiki/Building Reference Building DRI - Check this for link updates.]
+
*mesa - installs the mesa GL libs - Install this with pacman.
+
*libgl - installs the gl libs (part of the 'official' mesa source tree) (). - install this with pacman
+
*libdrm - installs the drm libs - install this with pacman
+
*xf86-video-mach64 - installs the xorg driver
+
*mach64-dri - installs the dri files for mach64
+
 
+
Terminology
+
*DRM - the kernel module that controls DMA, AGP memory management, resource locking, and secure hardware access.
+
*DRI - Direct Rendering Infrastructure - The X Server Driver. This allows the X server to communicate with the Graphics Card, translating OpenGL into instructions for the video card.
+
 
+
==Building the Kernel Drm Module - with makepkg goodness==
+
[[#Why Isn't the Mach64 DRM Included In the Kernel?|'''Before you start: Security Hole Warning''']]
+
Since kernel 2.6.27, The in tree DRM is no longer compatible with the mach64 drm. The kernel '''must''' be compiled as follows:
+
 
+
Device Drivers --->
+
        Graphics Support --->
+
                    < > Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  --->  (CONFIG_DRM=n) Must be disabled.
+
 
+
If you are using the standard Arch kernel, you must either recompile the kernel or obtain the AUR package [http://aur.archlinux.org/packages.php?ID=22785 kernel26-nodrm].
+
 
+
After your kernel is properly configured, install the AUR package [http://aur.archlinux.org/packages.php?ID=17939 mach64drm], which will install the kernel modules compiled from out of tree DRI sources.
+
 
+
==Installing the other end: DRI==
+
The new Xorg (1.5.3) brought with it a new driver structure, which included a separate package for the mach64, giving users a mach64 package without having to recompile like with previous Xorg servers. (previously, xf86-video-ati had to be modified to compile mach64 when it was built).
+
 
+
This has made the process of installing DRI much easier, entailing:
+
 
+
pacman -S xf86-video-mach64
+
 
+
==xorg.conf==
+
This is what my the Device section in my xorg.conf looks like:
+
  
 
  Section "Device"
 
  Section "Device"
Line 59: Line 27:
 
         Option "BufferSize" "2"
 
         Option "BufferSize" "2"
 
         Option "LocalTextures" "true"
 
         Option "LocalTextures" "true"
 +
        # Uncomment the following option if X segfaults as soon as anything using acceleration is called.
 +
        # Option "ExaNoComposite" "true"
 +
        # The following line will also prevent segmentation faults, but is not recommended since
 +
        # it will disable all acceleration.
 +
        # Option "NoAccel" "true"
 +
        # The following enables the shadow framebuffer, which improves non-accelerated performance.
 +
        # Use only with the "NoAccel" option.
 +
        # Option "ShadowFB" "true"
 
  EndSection
 
  EndSection
  
Line 70: Line 46:
 
*LocalTextures: boolean, by default, AGP cards will only use AGP memory for textures. To force using local card memory for textures in addition to AGP, you may set this option to true.
 
*LocalTextures: boolean, by default, AGP cards will only use AGP memory for textures. To force using local card memory for textures in addition to AGP, you may set this option to true.
 
The AgpSize option changes the amount of system memory used for the AGP aperture and is not limited by the size of the card's on-board video memory. This memory is used for the DMA buffers BufferSize option), and the remainder is allocated for AGP textures. Of course, the AgpMode/AgpSize options are ignored for PCI cards or if ForcePCIMode is enabled on an AGP card. However, the BufferSize option can be used to change the size of the DMA buffers in system memory for both PCI and AGP cards (but it's not recommended to reduce the buffer size unless you are short on system RAM).
 
The AgpSize option changes the amount of system memory used for the AGP aperture and is not limited by the size of the card's on-board video memory. This memory is used for the DMA buffers BufferSize option), and the remainder is allocated for AGP textures. Of course, the AgpMode/AgpSize options are ignored for PCI cards or if ForcePCIMode is enabled on an AGP card. However, the BufferSize option can be used to change the size of the DMA buffers in system memory for both PCI and AGP cards (but it's not recommended to reduce the buffer size unless you are short on system RAM).
<strike>[http://www.retinalburn.net/linux/dri_status.html]</strike> (dead link)
+
*ExaNoComposite - Required to prevent segmentation faults in EXA handler.
  
 
The Modules Section:
 
The Modules Section:
Line 92: Line 68:
 
  EndSection
 
  EndSection
  
==Testing DRI==
+
==Testing direct rendering==
After you're in X, you can run the command <code>glxinfo | egrep "direct rendering|OpenGL renderer"</code>
+
Restart X. After you are in X, you can run the command:
 +
$ glxinfo | egrep "direct rendering|OpenGL renderer"
 
This should return something like this:
 
This should return something like this:
  direct rendering: Yes
+
  Direct rendering: Yes
 
  OpenGL renderer string: Mesa DRI Mach64 [Rage Pro] 20051019 AGP 2x x86/MMX/SSE
 
  OpenGL renderer string: Mesa DRI Mach64 [Rage Pro] 20051019 AGP 2x x86/MMX/SSE
  
If OpenGL renderer string says "Software Rasterizer," DRI is not working, even if direct rendering says "yes"
+
If OpenGL renderer string says "Software Rasterizer", DRI is not working, even if direct rendering says "yes".
 
+
==Why Isn't the Mach64 DRM Included In the Kernel?==
+
The [http://dri.freedesktop.org/wiki/ATIMach64 official page] for the dri/drm driver for mach64 states:
+
 
+
"The reason the Mach64 driver isn't built by default yet is due to lack of proper security. At the moment, despite the fact that the client submitted buffers are checked and copied, a malicious client can change the buffer contents after the check/copy because _all_ buffers are mapped on client space. Therefore security can be compromised by using the Mach64 bus mastering abilities to read/write from/to system memory.
+
 
+
Things that need to be done:
+
*Provide a mechanism to allocate private DMA buffers which aren't mapped into the clients. The current DRM DMA buffer API is both arcane and incomplete in this this aspect. A new API is being worked, and is useable if these private DMA buffers are allocated by the DRM instead of the DDX. I'm merging into Mach64 branch as I speak, so this point can be considered done.
+
*Allocate and manage the private DMA buffers from above in Mach64 DRM. See http://sourceforge.net/mailarchive/forum.php?thread_id=1925221&forum_id=7177 for a more detailed description of what to do. Besides having to basically write a new/separate buffer management code we also need to integrate it with the existing one. The reason we need to keep the current buffer management code is that plain texture/bitmap data is of no security concern and needs to be dispatched as fast as possible, which means no copying into private buffers.
+
There are more things were the Mach64 driver needs a little work but the items above are the ones preventing it to be merged into the DRI trunk, and upstream.
+
 
+
As an update, the driver is waiting for some changes I'm preparing for the DRM common code that will allow the managament of several DMA buffers pools.
+
I can't really give a timeframe to driver completion - my laptop went dead several months ago and it's no longer something that affects me directly. Still I'm commited to finish it as my time permits it."
+
 
+
==Building the Kernel Drm Module - the Old Way without pacman==
+
warning: this does not use the makepkg method, which is recommended. Please use the AUR packages (top of this document) or create your own.
+
Skip this section if you did the section above, with makepkg.
+
 
+
The standard ARCH kernel doesn't come with the mach64 DRM module, so building yourself is required.
+
 
+
*Create a build folder to keep things tidy - this folder will be referred to from now on as $BUILDDIR
+
*Now, obtain the drm source tree:
+
git clone git://anongit.freedesktop.org/git/mesa/drm
+
*Get the thing compiled: (the drm folder appeared out of git)
+
cd $BUILDDIR/drm/linux-core/
+
make DRM_MODULES="mach64"
+
*Go get some coffee or something since your machine is probably very old to have a mach64 chipset and wait while everything compiles.
+
*When it's done compiling, there will be two files, <code>mach64.ko</code>, the device kernel module, and <code>drm.ko</code>, the DRM generic module.
+
*Copy those two files to the appropriate kernel modules directory. (Before doing this you may want to backup the exisiting files to somewhere else just in case).
+
sudo cp mach64.ko drm.ko /lib/modules/`uname -r`/kernel/drivers/char/drm/
+
*Now get the modules registered and depedencies generated.
+
sudo depmod -a `uname -r`
+

Revision as of 05:21, 28 January 2013

The Mach 64 chip is an old graphic accelerator developped by ATI. This board has basic 3D capabilites. Its support on Linux is poor but exists. This page is a walkthrough to setup Mach 64 graphics chipsets (including ATI Rage Pro) and obtain direct rendering on some of them.

Installing the basic features

2D and Xv acceleration in X can be achieved with xf86-video-mach64:

# pacman -S xf86-video-mach64

3D acceleration and direct rendering

Warning: You may experience crashes if using the Mach 64 DRM module. Direct rendering on Mach 64 is not very reliable because it never got much support.

On Linux, the Mach 64 chip uses the DRI/DRM system for direct rendering. The DRI part is available in [community], but the DRM module is not included in the mainline kernel. So we have to build it separately. A package in the AUR simplifies this task: mach64drmAUR.

As soon as the DRM module is built and installed, make sure you installed the DRI part:

# pacman -S mach64-dri

Configuration

Here is an example of X configuration for a Mach 64 chip (may not be mandatory in all cases):

Section "Device"
       Identifier  "Card0"
       Driver      "mach64"
       Card        "ATI Rage Pro - Mach64"
       Option "DMAMode" "async"
       Option "ForcePCIMode" "false"
       Option "AgpMode" "2"
       Option "AgpSize" "32"
       Option "BufferSize" "2"
       Option "LocalTextures" "true"
       # Uncomment the following option if X segfaults as soon as anything using acceleration is called.
       # Option "ExaNoComposite" "true"
       # The following line will also prevent segmentation faults, but is not recommended since
       # it will disable all acceleration.
       # Option "NoAccel" "true"
       # The following enables the shadow framebuffer, which improves non-accelerated performance.
       # Use only with the "NoAccel" option.
       # Option "ShadowFB" "true"
EndSection

Details:

  • Driver: most important, allows you to use the mach64 driver.
  • DMAMode: async - default, sync (synchronous DMA), mmio (PIO/MMIO) - Dispatch Buffers.
  • ForcePCIMode: boolean, disables AGP aperture. Set to True if you have a PCI card.
  • AgpMode (AGP 1x or 2x): 1 or 2. If not set, defaults to agpgart's mode.
  • AgpSize: sets the AGP aperture in MB - The video card can access this amount of system memory using AGP and shared access in order to expand its memory capacity - enlarging this allows more textures to be stored here.
  • BufferSize: sets DMA buffer memory size in MB. Default is 2 MB. May be 1 or 2.
  • LocalTextures: boolean, by default, AGP cards will only use AGP memory for textures. To force using local card memory for textures in addition to AGP, you may set this option to true.

The AgpSize option changes the amount of system memory used for the AGP aperture and is not limited by the size of the card's on-board video memory. This memory is used for the DMA buffers BufferSize option), and the remainder is allocated for AGP textures. Of course, the AgpMode/AgpSize options are ignored for PCI cards or if ForcePCIMode is enabled on an AGP card. However, the BufferSize option can be used to change the size of the DMA buffers in system memory for both PCI and AGP cards (but it's not recommended to reduce the buffer size unless you are short on system RAM).

  • ExaNoComposite - Required to prevent segmentation faults in EXA handler.

The Modules Section:

Section "Module"
       <Your modules>
       Load  "glx"
       Load  "dri"
EndSection

The DRI Section:

Section "DRI"
       Mode 0666 #allows anybody to use DRI
EndSection

The DRI Section (For machines where security is a concern):

Section "DRI"
       Group "video" #change to any desired group to restrict access
       Mode 0660
EndSection

Testing direct rendering

Restart X. After you are in X, you can run the command:

$ glxinfo | egrep "direct rendering|OpenGL renderer"

This should return something like this:

Direct rendering: Yes
OpenGL renderer string: Mesa DRI Mach64 [Rage Pro] 20051019 AGP 2x x86/MMX/SSE

If OpenGL renderer string says "Software Rasterizer", DRI is not working, even if direct rendering says "yes".