# Intel GMA945 gmabooster.sh



## flatr0ze (Jun 17, 2011)

Hello, I need some help with pciconf.

There's a video chip, called Intel GMA945 (sometimes, GMA950), it's being included inside of a lot of netbooks and even notebooks/desktop PCs. On netbooks, the bus is underclocked to 200 MHz, to save the power and to lower the heat being produced by it. There was a tool called gmabooster, both for Windows and Linux. What it does is that it simply sets the FSB of that chip back to 250\400 MHz and here you go -- you get a faster performance, no more underclocking.

There's a shareware tool from one greedy programmer available for Windows, while for Linux it was possible to do with this simple sh script:

```
#!/bin/sh

case "$1" in
    250) val=31 ;;
    400) val=33 ;;
    200) val=34 ;;
    *)
        echo "Illegal argument! Possible values are: 200, 250, 400." >&2
        exit 1
    ;;
esac

setpci -s 02.0 f0.b=00,60
setpci -s 02.0 f0.b=$val,05
```

02.0 is the address of our VGA adapter in Linux, found by lspci:

```
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GME Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
```

Now, here's the deal: there's no setpci tool available for FreeBSD. The closest one I found was pciconf, but there's absolutely no information on the web about how to work with it.

Here's a part we need, from the output of *pciconf -lvbc*:

```
vgapci0@pci0:0:2:0:	class=0x030000 card=0x83401043 chip=0x27ae8086 rev=0x03 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Mobile 945 Express Chipset Family'
    class      = display
    subclass   = VGA
    bar   [10] = type Memory, range 32, base 0xf7f00000, size 524288, enabled
    bar   [14] = type I/O Port, range 32, base 0xec00, size  8, enabled
    bar   [18] = type Prefetchable Memory, range 32, base 0xd0000000, size 268435456, enabled
    bar   [1c] = type Memory, range 32, base 0xf7ec0000, size 262144, enabled
    cap 05[90] = MSI supports 1 message 
    cap 01[d0] = powerspec 2  supports D0 D3  current D0
vgapci1@pci0:0:2:1:	class=0x038000 card=0x83401043 chip=0x27a68086 rev=0x03 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Mobile 945GM/GU Express Integrated Graphics Controller'
    class      = display
    bar   [10] = type Memory, range 32, base 0xf7f80000, size 524288, enabled
    cap 01[d0] = powerspec 2  supports D0 D3  current D0
```

It's pretty similar to Linux's one, as we can see.

What I cannot figure out is how to set the values. At first, I thought that cap 01 was the parameter I needed (d0 = null, d1 = 200, d2=250 and d3 = 400 MHz), but that powerspec D0 D3 is available almost for all PCI devices.

That's why I need some tough help here, considering how to set that f0.b=00,60 and f0.b=33,05 with pciconf.

Thank you!


----------



## lockdoc (Jun 18, 2011)

Hi,

I am using the same graphics card, so I am also quiet interested in this. A search on Google couldn't help me any further. Probably a look at the driver itself could helpful

x11-drivers/xf86-video-intel

```
/usr/ports/x11-drivers/xf86-video-intel/work/xf86-video-intel-2.7.1/src/ ]# 
user> grep -color=always -R hz ./
./modes/xf86EdidModes.c:    /* First detailed mode is bogus, prefer largest mode at 60[color="Red"]hz[/color] */
./i830_display.c:	/* The single-channel range is 25-112M[color="Red"]hz[/color], and dual-channel
./i830_display.c:	 * is 80-224M[color="red"]hz[/color].  Prefer single channel as much as possible.
./i830_display.c:    /* Wait for 20ms, i.e. one cycle at 50[color="red"]hz[/color]. */
./i830_display.c:     * The 830 may go up to 166 M[color="red"]hz[/color], which we should check.
./i830_display.c:		   "Chosen PLL clock of %.1f M[color="red"]hz[/color] more than 2%% away from "
./i830_display.c:		   "desired %.1f M[color="red"]hz[/color]\n",
./xvmc/I810XvMC.c:  usleep(20000);  /* 1/50th Sec for 50[color="red"]hz[/color] refresh */
./i830_sdvo.c:	    /* Clock range is required to be in 100-200M[color="red"]hz[/color] */
./i810_reg.h: * SDVO requires that the bus clock rate be between 1 and 2 G[color="red"]hz[/color], and the bus
./i810_reg.h: * So, for a mode with a dotclock of 65M[color="red"]hz[/color], we would want to double the clock
./i810_reg.h: * rate to 130M[color="red"]hz[/color] to get a bus rate of 1.30G[color="red"]hz[/color].  The DPLL clock rate would be
./i810_reg.h: * set to 130M[color="red"]hz[/color], and the SDVO multiplier set to 2x in this register and
./i830_bios.h:    uint16_t dclk;		/**< In 10k[color="red"]hz[/color] */
```

x11-drivers/xf86-video-intel29

```
/usr/ports/x11-drivers/xf86-video-intel29/work/xf86-video-intel-2.9.1/src/ ]# 
user> grep -color=always -R hz ./
./i830_bios.h:    uint16_t dclk;		/**< In 10k[color="Red"]hz[/color] */
./i810_reg.h: * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
./i810_reg.h: * So, for a mode with a dotclock of 65M[color="red"]hz[/color], we would want to double the clock
./i810_reg.h: * rate to 130M[color="red"]hz[/color] to get a bus rate of 1.30G[color="red"]hz[/color].  The DPLL clock rate would be
./i810_reg.h: * set to 130M[color="red"]hz[/color], and the SDVO multiplier set to 2x in this register and
./i830_debug.c:	    refclk = "default 120M[color="red"]hz[/color]";
./i830_debug.c:	    refclk = "SuperSSC 120M[color="red"]hz[/color]";
./xvmc/I810XvMC.c:  usleep(20000);  /* 1/50th Sec for 50[color="red"]hz[/color] refresh */
./i830_display.c:	/* The single-channel range is 25-112M[color="red"]hz[/color], and dual-channel
./i830_display.c:	 * is 80-224M[color="red"]hz[/color].  Prefer single channel as much as possible.
./i830_display.c:    /* Wait for 20ms, i.e. one cycle at 50[color="red"]hz[/color]. */
./i830_display.c:     * The 830 may go up to 166 M[color="red"]hz[/color], which we should check.
./i830_display.c:		   "Chosen PLL clock of %.1f M[color="red"]hz[/color] more than 2%% away from "
./i830_display.c:		   "desired %.1f M[color="red"]hz[/color]\n",
./i830_sdvo.c:	    /* Clock range is required to be in 100-200M[color="red"]hz[/color] */
./i830_sdvo.c:            /* Clock range is required to be in 100-200M[color="red"]hz[/color] */
```


----------



## wblock@ (Jun 18, 2011)

flatr0ze said:
			
		

> ```
> setpci -s 02.0 f0.b=00,60
> setpci -s 02.0 f0.b=$val,05
> ```



Step 1: explain exactly what that's doing.  -s 02.0 is selecting the card...  There's a man page for setpci, but it's not helping much.

Step 2: translate it to FreeBSD.  The -w option to pciconf(8) will probably do it.

Step 3: wonder where that burning smell is coming from.


----------



## lockdoc (Jun 18, 2011)

Reading this from the manual:


```
...
bus  (0 to  ff),
slot (0  to  1f) and
function (0 to 7)
...
"0.3" selects third function of device 0 on all buses
```

Step 1:
I would say -s 02.0 means: select 0th function of device 02 on all buses. But I am not 100% sure.

Step 2:
This is about finding the appropriate function on a FreeBSD system. As he states above, he is not sure which is the corresponding function in FreeBSD, because pciconf is not saying anything about FSB speed.


----------



## flatr0ze (Jun 18, 2011)

No, -s 02.0 is the address of the PCIi device in Linux, look:

```
00:02.0 VGA compatible controller: Intel C... bla-bla-bla
```
Under FreeBSD, there's a similar address, it looks like this: 
	
	



```
pci0:0:2:0
```

I've tried to set the value with pciconf like this: `pciconf -wb pci0:0:2:0 01 d2` but it didn't work out. I need to find out how to modify the value "f0.b" in FreeBSD. It should be 31,33 and 34 too, I guess...


----------



## lockdoc (Jun 18, 2011)

```
cap 01[d0] = powerspec 2  supports D0 D3  current D0
```

It doesn't say anything of D2.


----------



## flatr0ze (Jun 18, 2011)

Yes, but that's not the value I need to change anyway, I was wrong with cap 01.

However, I get no error, by executing these two:
`pciconf -w pci0:0:2:0 f0.b 00,60`
`pciconf -w pci0:0:2:0 f0.b 34,05`

Have no idea how to check if it's working or not though.


----------



## lockdoc (Jun 18, 2011)

You could indirectly test it by either benchmarking the "before" and "after" and/or monitoring the temperature.

I am also trying to find out where to get more information about the hardware. Also no luck with sysctl


----------



## lockdoc (Jun 19, 2011)

Hi,

You will probably want to have a look at sysutils/pciutils It contains the lspci, setpci and update-pciids. The Project's website is: http://mj.ucw.cz/pciutils.html

Good luck. Please let me know any success on this.


----------



## flatr0ze (Jun 19, 2011)

Thank you very much for this info, lockdoc! I just installed it from ports, and used the Linux gmabooster.sh script. Now I have to make sure it's working, along with pciconf's commands.

720p has not much to do with it really, it's more like CPU stuff, but some game would tell the difference.

Oh, and after all, a little note. I'm glad there's a pciutils pack available for *BSD, but I feel like I'm cheating on my OS. I mean, there's a native BSD pciconf tool available, just no info on how to use it.


----------



## lockdoc (Jun 19, 2011)

Hi flatr0ze,

Can you tell me how to read out with the pciconf the modes? I am using the same graphics card as you, but even with this tool I could not find something telling me about the bus speed.


----------



## flatr0ze (Jun 19, 2011)

Well, to be honest, I'm not sure I can tell much.
I've used
`# pciconf -lvbc`
to get as much info as possible from pciconf, but it doesn't really say anything about modes, plus it's only allowed to be run as root.

I'm going to investigate the performance soon, benchmarking that thing pciutils, you found.


----------

