# Dirty workaround for AGP8x Radeon 9x00 users? Success!!

## jhboricua

I stumble onto this pdf file that explains the physical differences between a agp4x and 8x card.

http://www.jhboricua.org/AGP8Xvs4X.pdf

Now, If I were to sever the link on this pin on my 9700, would it force the mobo to view it as a agp4x card and switch to agp4x mode accordingly?  In theory it seems like it should but I'd like opinions on this.  The only reason for me doing this is that I'm sick and tired of not being able to use my radeon accelerated on X because even though agp8x is being out so long, the current 2.4 kernel series don't support it and I can't make it work in my Gygabyte mobo.  I can't force the mobo to agp4X on the bios either, so I'm thinking preventing the mobo from sensing this pin will make it default to agp4x and will let me use the ati-drivers.  It wouldn't be too hard to re-enable the pin later either.  Views on this?Last edited by jhboricua on Tue Jul 08, 2003 10:29 am; edited 1 time in total

----------

## Peaceable Frood

The 2.4 series do not support 8x, the 2.5 series do though.

----------

## jhboricua

What good is it if the ati-drivers can't be built against the 2.5 development series?  Besides, that is not what this thread is about.

----------

## Peaceable Frood

 *jhboricua wrote:*   

> What good is it if the ati-drivers can't be built against the 2.5 development series?  Besides, that is not what this thread is about.

 

Is there something that you can edit with in the drivers to force into 4x like the nVidia drivers, have. I don't have an ATI card anymore for reasons just like this, so I don't know how it's setup.

----------

## deathdruid

 *Peaceable Frood wrote:*   

> Is there something that you can edit with in the drivers to force into 4x like the nVidia drivers, have. 

 

Actually, yes.

```
Option "AGPMode" "4"
```

should do the job. Does that not work?

Meanwhile, the in-kernel 2.5 radeon driver is working really well for me. You might want to give dev-kernels a shot.

----------

## jhboricua

That won't work because it doesn't even recognize the ATI card and X never starts, much less is  force an AGP setting.

----------

## darkangael

the latest ati-drivers (2.9.12) works fine with agp8x.

----------

## jhboricua

*sight*

No they don't.  Haven't u seen all the threads?  AGP 3.0 mode is not working on VIA KT-400 motherboards with the ati drivers.  The last time I got it to work was under xfree 4.2 and the 2.5.1 ati-drivers by backporting some agp3 code from the 2.5 kernel series.  But that stopped working with the xfree 4.3 ati-drivers that followed.  I believe Nforce2 users have a difference experience as I think the drivers do work on their mobo with nvidia's nforce2 drivers and some work, but VIA users that can't change the AGP mode on their BIOS are left with just VESA as their only option of running X.

Anyways, on another update, I did manage to get my card working.  How you ask?  Well, the dirty workaround that is the subject of this thread indeed works.  On the Radeon 9700 boards, the ones that follow ATI's reference design, pins A3 and A11 on the edge connector are the ones that control whether the board will operate at AGP 3.0 or AGP 2.0 mode.  They each connect to a 0 ohm resistor.  You can either cut/unsolder those resistors or cut the trace from those pins to them carefully with a small knife and voila!, your 9700 will operate at AGP 4x on a AGP 8x mobo.  Then just compile the drivers, run fglrxconfig and fire X.  You'll be pleased.

It worked for me.  Why castrate the card, you ask?  Well, most benchmarks so far agree that the performance gain from agp4 to agp8 is negligible.  I figure by the time the kernel supports VIA's agp 3.0 chipset, I'll prolly have a new card  and really, what good is to have the card if I can't exploit it under linux?  So I took a little utility knife and carefully severed the traces going to the resistors on those pins.  I  am now running X with 3d acceleration using the 2.9.13 ATI drivers.  My glxgear scores are:

22674 frames in 5.0 seconds = 4534.800 FPS

22839 frames in 5.0 seconds = 4567.800 FPS

22878 frames in 5.0 seconds = 4575.600 FPS

22696 frames in 5.0 seconds = 4539.200 FPS

22790 frames in 5.0 seconds = 4558.000 FPS 

This using ck-sources.  Will try gaming-sources later today.  If you guys are interested I can post some pics of my card and the pins in question.  Now I can go to sleep.

----------

## darkangael

sorry, I forgot that I added a patch that someone made for the 2.5.x series of ati-drivers that made it work. I don't know exactly where to find hte patch (couldnt find it anywhere last time i looked) but if you really need it i could possibly e-mail it to you. (of course if you have severed the pin it's already too late, but anyone else feel free to ask. I could also find some web hosting if it is popular enough i guess...) I think the patch just adds an id for the kt400 and perhaps makes one ofthe registers the right size for agp8x (the only major difference from what i have heard between the two)Last edited by darkangael on Wed Jul 09, 2003 3:08 am; edited 1 time in total

----------

## darkangael

sorry, I forgot that I added a patch that someone made for the 2.5.x series of ati-drivers that made it work. I put a patched ebuild in the overlay, so when the ebuild worked after an emerge sync I assumed I didn't need it anymore  :Wink:  I don't know exactly where to find the patch (couldnt find it anywhere last time i looked)  so I will put it on the board to copy/paste.Last edited by darkangael on Wed Jul 09, 2003 3:06 am; edited 1 time in total

----------

## darkangael

better idea, here is the patch: (i got it from this forum, so it should also be somewhere else but this is easier, i take no credit, just want people to have it available  :Wink: 

```

--- build_mod/agp.h     2002-11-27 14:53:19.000000000 -0500

+++ build_mod_kt400/agp.h       2003-02-10 15:19:33.000000000 -0500

@@ -47,8 +47,9 @@

 #define _FGL_AGP_H

 // build config defines

+#ifndef VIA_KT400_AGP3

 #define FGL_USE_AGPV3_OFFICIAL_ENABLE       /* use offical AGP V3 code */

-

+#endif

 // helper defines - for any public source of firegl code tree.

 // min/max defines taken from include/linux/kernel.h of linux-2.4.10-pre9

@@ -837,6 +838,12 @@

 #define VIA_APSIZE      0x84

 #define VIA_ATTBASE     0x88

+/* VIA KT400 */

+#define VIA_AGP3_GARTCTRL 0x90

+#define VIA_AGP3_APSIZE          0x94

+#define VIA_AGP3_ATTBASE  0x98

+#define VIA_AGPSEL        0xfd

+

 /* SiS registers */

 #define SIS_APBASE      0x10

 #define SIS_ATTBASE     0x90

--- build_mod/agpgart_be.c      2002-11-27 14:53:19.000000000 -0500

+++ build_mod_kt400/agpgart_be.c        2003-02-10 15:21:09.000000000 -0500

@@ -2561,6 +2561,8 @@

     (void) pdev; /* unused */

 }

+#ifndef VIA_KT400_AGP3

+

 static int via_fetch_size(void)

 {

        int i;

@@ -2619,6 +2621,63 @@

        pci_write_config_dword(agp_bridge.dev, VIA_GARTCTRL, 0x0000000f);

 }

+#else

+

+static int via_fetch_size(void)

+{

+       int i;

+       u16 temp;

+       struct aper_size_info_16 *values;

+

+       values = A_SIZE_16(agp_bridge.aperture_sizes);

+       pci_read_config_word(agp_bridge.dev, VIA_AGP3_APSIZE, &temp);

+       for (i = 0; i < agp_bridge.num_aperture_sizes; i++) {

+               if (temp == values[i].size_value) {

+                       agp_bridge.previous_size =

+                       agp_bridge.current_size = (void *) (values + i);

+                       agp_bridge.aperture_size_idx = i;

+                       return values[i].size;

+               }

+       }

+       return 0;

+}

+

+static int via_configure(void)

+{

+       u32 temp;

+       struct aper_size_info_16 *current_size;

+

+       current_size = A_SIZE_16(agp_bridge.current_size);

+

+       /* address to map too */

+       pci_read_config_dword(agp_bridge.dev, VIA_APBASE, &temp);

+       agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);

+

+       /* attbase - aperture GATT base */

+       pci_write_config_dword(agp_bridge.dev, VIA_AGP3_ATTBASE,

+               agp_bridge.gatt_bus_addr & 0xfffff000);

+       return 0;

+}

+

+static void via_cleanup(void)

+{

+       struct aper_size_info_16 *previous_size;

+

+       previous_size = A_SIZE_16(agp_bridge.previous_size);

+       pci_write_config_byte(agp_bridge.dev, VIA_APSIZE, previous_size->size_value);

+}

+

+static void via_tlbflush(agp_memory * mem)

+{

+       u32 temp;

+

+       pci_read_config_dword(agp_bridge.dev, VIA_AGP3_GARTCTRL, &temp);

+       pci_write_config_dword(agp_bridge.dev, VIA_AGP3_GARTCTRL, temp & ~(1<<7));

+       pci_write_config_dword(agp_bridge.dev, VIA_AGP3_GARTCTRL, temp);

+}

+

+#endif

+

 static unsigned long via_mask_memory(unsigned long addr, int type)

 {

        /* Memory type is ignored */

@@ -2626,6 +2685,8 @@

        return addr | agp_bridge.masks[0].mask;

 }

+#ifndef VIA_KT400_AGP3

+

 static struct aper_size_info_8 via_generic_sizes[7] =

 {

        {256, 65536, 6, 0},

@@ -2637,6 +2698,24 @@

        {4, 1024, 0, 252}

 };

+#else

+

+static struct aper_size_info_16 via_generic_sizes[11] =

+{

+       { 4,     1024,  0, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3|1<<2|1<<1|1<<0 },

+       { 8,     2048,  1, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3|1<<2|1<<1},

+       { 16,    4096,  2, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3|1<<2},

+       { 32,    8192,  3, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3},

+       { 64,   16384,  4, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4},

+       { 128,  32768,  5, 1<<11|1<<10|1<<9|1<<8|1<<5},

+       { 256,  65536,  6, 1<<11|1<<10|1<<9|1<<8},

+       { 512,  131072, 7, 1<<11|1<<10|1<<9},

+       { 1024, 262144, 8, 1<<11|1<<10},

+       { 2048, 524288, 9, 1<<11}       /* 2GB <- Max supported */

+};

+

+#endif

+

 static struct gatt_mask via_generic_masks[] =

 {

        {0x00000000, 0}

@@ -2648,7 +2727,11 @@

        agp_bridge.num_of_masks = 1;

        agp_bridge.aperture_sizes = (void *) via_generic_sizes;

        agp_bridge.size_type = U8_APER_SIZE;

+#ifndef VIA_KT400_AGP3

        agp_bridge.num_aperture_sizes = 7;

+#else

+       agp_bridge.num_aperture_sizes = 11;

+#endif

        agp_bridge.dev_private_data = NULL;

        agp_bridge.needs_scratch_page = FALSE;

        agp_bridge.configure = via_configure;

--- build_mod/make.sh   2002-11-27 14:53:19.000000000 -0500

+++ build_mod_kt400/make.sh     2003-02-08 22:44:23.000000000 -0500

@@ -781,7 +781,7 @@

 # ==============================================================

 # defines for all targets

-def_for_all="-DATI_AGP_HOOK -DATI -DFGL -D${target_define} -DFGL_CUSTOM_MODULE"

+def_for_all="-DATI_AGP_HOOK -DATI -DFGL -D${target_define} -DFGL_CUSTOM_MODULE -DVIA_KT400_AGP3"

 # ==============================================================

```

[/code]

----------

## darkangael

and here is the ebuild script for it (note: the filename for the patch was fglrx-glc22-4.2.0-2.5.1.i586-kt400agp3.patch on my machine, as that si what it was originally for)

```

# Copyright 1999-2003 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-x86/media-video/ati-drivers/ati-drivers-2.9.13.ebuild,v 1.2 2003/05/19 21:57:09 lu_zero Exp $

IUSE="qt kde gnome"

DESCRIPTION="Ati precompiled drivers for r300, r250 and r200 chipsets"

HOMEPAGE="http://www.ati.com"

SRC_URI="mirror://gentoo/fglrx-glc22-4.3.0-${PV}.i586.tar.gz"

SLOT="${KV}"

LICENSE="ATI GPL-2 QPL-1.0"

KEYWORDS="-* x86"

DEPEND=">=virtual/linux-sources-2.4

        >=x11-base/xfree-4.3.0

        qt? ( >=x11-libs/qt-3.0 )"

RDEPEND="qt? ( >=x11-libs/qt-3.0 )"

ATIBIN="${D}/opt/ati/bin"

RESTRICT="nostrip"

src_unpack() {

    cd ${WORKDIR}

        tar zxf ${DISTDIR}/fglrx-glc22-4.3.0-${PV}.i586.tar.gz || die

        mkdir ${WORKDIR}/fglrxgears

        cd ${WORKDIR}/fglrxgears

        tar zxf ${WORKDIR}/usr/src/fglrx_sample_source.tgz || die

        mv xc/programs/fgl_glxgears/* .

        cp Makefile.Linux Makefile.Linux.orig || die

        #defining USE_GLU allows this to compile with NVIDIA headers just fine

        sed -e "s:-I/usr/X11R6/include:-D USE_GLU -I/usr/X11R6/include:" Makefile.Linux.orig > Makefile.Linux || die

        cd ${WORKDIR}

        local OLDBIN="/usr/X11R6/bin"

        local ATIBIN="${D}/opt/ati/bin"

        mkdir fglrx_panel

        cd fglrx_panel

        tar zxf ${WORKDIR}/usr/src/fglrx_panel_sources.tgz || die

        sed -e "s:"${OLDBIN}":"${ATIBIN}":"\

        Makefile >Makefile.new

        mv Makefile.new Makefile

}

pkg_setup(){

        check_KV || die "please ensure /usr/src/linux points to your kernel symlink"

}

src_compile() {

        einfo "applying agp 3.0 patch"

    cp /usr/portage/distfiles/fglrx-glc22-4.2.0-2.5.1.i586-kt400agp3.patch ${WORKDIR}/lib/modules/fglrx

    cd ${WORKDIR}/lib/modules/fglrx

    cat fglrx-glc22-4.2.0-2.5.1.i586-kt400agp3.patch | patch -p0

        einfo "building the glx module"

        cd ${WORKDIR}/lib/modules/fglrx/build_mod

        #that is the dirty way to avoid the id -u check

        sed -e 's:`id -u`:0:' make.sh >make.sh.new

        sed -e 's:`uname -r`:${KV}:' make.sh.new >make.sh

        chmod +x make.sh

        ./make.sh || ewarn "glx module not built"

        einfo "building the fgl_glxgears sample"

        cd ${WORKDIR}/fglrxgears

        make -f Makefile.Linux || ewarn "fgl_glxgears sample not build"

        if [ "`use qt`" ]

        then

        einfo "building the qt fglx panel"

                cd ${WORKDIR}/fglrx_panel

                emake || die

        fi

        #removing stuff

        einfo "cleaning"

        cd ${WORKDIR}

        rm -fR usr/share

        cd usr/X11R6/

        rm -fR bin/firegl*.bz2 bin/LICENSE.* bin/fgl_glxgears src

}

pkg_preinst() {

# clean the dinamic libGL stuff's home to ensure

# we dont have stale libs floating around

        if [ -d ${ROOT}/usr/lib/opengl/ati ]

        then

                rm -rf ${ROOT}/usr/lib/opengl/ati/*

        fi

}

src_install() {

        local ATI_ROOT="/usr/lib/opengl/ati"

        cd ${WORKDIR}

#drm module

        insinto /lib/modules/${KV}/video

        doins lib/modules/fglrx/build_mod/fglrx.o

#dri driver

        exeinto ${ATI_ROOT}/lib

        doexe usr/X11R6/lib/libGL.so.1.2

        dosym libGL.so.1.2 ${ATI_ROOT}/lib/libGL.so.1

        dosym libGL.so.1.2 ${ATI_ROOT}/lib/libGL.so

        dosym libGL.so.1.2 ${ATI_ROOT}/lib/libMesaGL.so

        #that is the same as in the xfree

        dosym ../../xfree/lib/libGL.la ${ATI_ROOT}/lib/libGL.la

#same as in xfree

        exeinto ${ATI_ROOT}/

        dosym ../xfree/include ${ATI_ROOT}/include

        dosym ../xfree/extensions ${ATI_ROOT}/extensions

        rm usr/X11R6/lib/libGL.so.1.2

#apps

        insinto /etc/env.d

        doins ${FILESDIR}/09ati

        exeinto /opt/ati/bin

        doexe fglrxgears/fgl_glxgears

        doexe usr/X11R6/bin/*

        rm usr/X11R6/bin/*

        if [ "`use qt`" ]

        then

                doexe fglrx_panel/fireglcontrol

        fi

        rm -f usr/src/*

        cp -R usr ${D}

}

pkg_postinst() {

        #Ebuild shouldn't do this automatically, just tell the user to do it: (drobbins, 1 May 2003)

        #otherwise it messes up livecd/gamecd stuff

        #if [ "${ROOT}" = "/" ]

        #then

        #       /usr/sbin/opengl-update ati

        #fi

        einfo "To switch to ATI OpenGL, run \"opengl-update ati\""

        einfo "To chance your XF86Config you can use the bundled \"fglrxconfig\""

#drm-module

        update-modules

}

```

----------

## jhboricua

I remember that patch darkangel, I was the one who made the modified ebuild for the 2.5.1 drivers so they could use it. 

https://forums.gentoo.org/viewtopic.php?t=37488&highlight=radeon

The problem is that the patch doesn't work anymore, as a matter of fact, the patch changes are already incorporated in the drivers.  If you look at the 2.9.13 driver for the agp related files you'll see that they already have those changes that are in the patch file already.  If you try to patch the file it will not build the module and complain about a malformed line thingie.  Look carefully when you run the ebuild.  It will clearly state that the module was not build and keep going with the rest of the stuff.

I still have not read from anyone that has been able to get the 2.9.12 or 2.9.13 drivers to work on a KT400 mobo at agp8x with or without the patch.

I'm curious, since you claim the drivers work, do you run a ati card at agp8x on a VIA kt400 mobo?

----------

## darkangael

Well i have no BIOS setting that allows me to change to agp4x, and with 2.9.12 I am pretty sure fireglcontrol said agp8x (cant get it working in 2.9.13 for some reason... segfault) and if I apply that patch, it works. I have a sapphire radeon 9700 pro, epox 8k9a series board (I think it's the 8k9a2+, it has the raid controller and SATA) and 512mb of ddr333. As far as I know it is in agp8x mode (and the fact that I actually did have to apply that patch would indicate it) so I would have to say yes, it is working in agp8x mode. It is at least working with no bios modification and definitely no butchering of the board  :Smile: 

----------

## darkangael

Confirmed, I just went and found their statically compiled version of fireglcontrol and that worked. It definitely says agp8x mode. Oh and it definitely built the moduel, cos i have done it on about 5 different kernels and unmerged the ati-drivers package a few times while fiddling with it to make it work better (and not succeeding hehe))

----------

## darkangael

and now the patch doesn't work anymore (3.2.5)  :Sad: . I tried the 2.6.x kernel with the external agpgart module and it works, although i still have the problems with neverwinter nights, and they get worse with 2.6 kernel

----------

