[Android Software/Hacking General [Developers Only]] FeraVolt:
"Hey Dev! Make those Snapdragons fly!"​

A little into:

Hello wonderful and amazing people! I'm Fera, ROM/Kernel developer from SonyXperia X10 forum. I'm 20 years old hungry student and I'd like to share a bit of my experience with you guys. Open Source rules! :highfive: Hacks listed here have to work despite kernel versions. I made this hacks specificly for

qsd8k

board, but you may try your luck on newer chipsets if you get the logic. Things are pretty similar on Snapdragon chipsets. I spent a lot of hard time figuring things out so if you like this stuff, hit 'Thanks' button, rate this thread, share it to let other people know, and feed me. :o

Now..enough for drama, have good music, tighten your belts, sit back and relax - we're going to fly at the speed of light.. :cool:

GPU and CPU overclocking:

I will show an example by overclocking my Sony Ericsson Xperia X10 retired phone with QSD8x50 Snapdragon S1 board with Adreno200 rev1 GPU onboard. You may look at more complex details list of Adreno GPU HERE.

Let's start now. This hack requiers to recompile kernel for your device. It's quite simple actually. To keep things more clear, let's note what we have:

grp_clock = Graphics clock //128000000 by default for adreno200 rev1
ebi1_clock = External Bus Interface 1 clock //256000000 by default for qsd8k
imem_clock = Internal Graphics Memory clock //256000000 by default for qsd8k

We're going to deal with grp_clock of Adreno bus clock and CPU clock itself.

In kernel sources under arch/arm/mach-msm we have acpuclock-8x50.c file. This file (or any equivalent to your board) contains actual CPU freq. table and misc hw stuff related to clocks.

Default freq. table for qsd8k is:

{ 0, 19200, ACPU_PLL_TCXO, 0, 0, 0, 0, 14000, 0, 0, 1000},
{ 0, 128000, ACPU_PLL_1, 1, 5, 0, 0, 14000, 2, 0, 1000},
{ 1, 245760, ACPU_PLL_0, 4, 0, 0, 0, 29000, 0, 0, 1000},
{ 1, 384000, ACPU_PLL_3, 0, 0, 0, 0, 58000, 1, 0xA, 1000},
{ 0, 422400, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xB, 1000},
{ 0, 460800, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xC, 1000},
{ 0, 499200, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xD, 1025},
{ 0, 537600, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xE, 1050},
{ 1, 576000, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xF, 1050},
{ 0, 614400, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0x10, 1075},
{ 0, 652800, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0x11, 1100},
{ 0, 691200, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0x12, 1125},
{ 0, 729600, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0x13, 1150},
{ 1, 768000, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x14, 1150},
{ 0, 806400, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x15, 1175},
{ 0, 844800, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x16, 1200},
{ 0, 883200, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x17, 1225},
{ 0, 921600, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x18, 1275},
{ 0, 960000, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x19, 1275},
{ 1, 998400, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x1A, 1300},

Little theory lesson:

Let's take last line and digest it..

1/0 - means that this clk ladder is enabled/disabled

998400 - Actual ladder freq. in Khz

ACPU_PLL_3, 0, 0, 0, 0 - AXI/PLL macros, adresses

128000 - AXI bus freq. in Khz

0/1/2 - Init adresses

0x1A - Step raw code for CPU

1300 - Voltage gained to corresponding freq. step in mV

We can see that we have 128000 freq. on top of the table set as 0 (disabled) for global access and reserved for PLL_1 which is adressed to 2. After hardcore testings I found out that this adresses to GPU AXI bus clock used by Adreno200. We simply change it to 192000Khz. Overclocking to higher values made my device very unstable, so don't bump high too much.

The ready line will be look as:

{ 0, 192000, ACPU_PLL_1, 1, 5, 0, 0, 14000, 2, 0, 1000 },

But it's not all. Note that this may vary in your .c file so turn on your brain and search for axi defines. In my case it was in same .c file in this function :

unsigned long clk_get_max_axi_khz(void)
{
return 128000;
}
EXPORT_SYMBOL(clk_get_max_axi_khz);

Find something similar to this (if it realy exists) and set value to 192000.

Now we have to update all CPU freq table with overclocked axi bus values which could be stable.. At this point I spent monthes of testing and finally came up to stable things. I will just paste here my table which also includes CPU overclock and undervolt:

{ 0, 19200, ACPU_PLL_TCXO, 0, 0, 0, 0, 14000, 0, 0, 1000 },
{ 0, 192000, ACPU_PLL_1, 1, 5, 0, 0, 14000, 2, 0, 1000 },
{ 1, 245760, ACPU_PLL_0, 4, 0, 0, 0, 29000, 0, 0, 1025 },
{ 1, 384000, ACPU_PLL_3, 0, 0, 0, 0, 58000, 1, 0xA, 1025 },
{ 0, 422400, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xB, 1025 },
{ 1, 460800, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xC, 1025 },
{ 0, 499200, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xD, 1025 },
{ 0, 537600, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xE, 1025 },
{ 1, 576000, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0xF, 1025 },
{ 0, 614400, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0x10, 1050 },
{ 0, 652800, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0x11, 1075 },
{ 0, 691200, ACPU_PLL_3, 0, 0, 0, 0, 117000, 1, 0x12, 1100 },
{ 0, 729600, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x13, 1125 },
{ 1, 768000, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x14, 1125 },
{ 0, 806400, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x15, 1150 },
{ 0, 844800, ACPU_PLL_3, 0, 0, 0, 0, 128000, 1, 0x16, 1200 },
{ 0, 883200, ACPU_PLL_3, 0, 0, 0, 0, 160000, 1, 0x17, 1225 },
{ 0, 921600, ACPU_PLL_3, 0, 0, 0, 0, 160000, 1, 0x18, 1250 },
{ 0, 960000, ACPU_PLL_3, 0, 0, 0, 0, 160000, 1, 0x19, 1275 },
{ 1, 998400, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x1A, 1300 },
{ 1, 1036800, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x1B, 1325 },
{ 1, 1075200, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x1C, 1325 },
{ 1, 1113600, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x1D, 1325 },
{ 1, 1152000, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x1E, 1350 },
{ 1, 1190400, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x1F, 1350 },
{ 1, 1228800, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x20, 1375 },
{ 1, 1267200, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x21, 1425 },
{ 1, 1305600, ACPU_PLL_3, 0, 0, 0, 0, 192000, 1, 0x22, 1425 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

This is how my table looks after GPU/CPU overclock/undervolt and hard testings. I find theese values solid stable and best at performance, exept last freq ladder. 1.3Ghz overclock is a bit overdose for my device (since it is max available freq. ladder for my cpu) but I save it in case there is a phone of mine with balls of steel (not all CPU chips are same and not all can handle overclocking). As you may notice, overclocked axi frequency is enabled on higher CPU clock steps. This means that axi overclock will be enabled when CPU runs on 1113Mhz and higher, so to enable all this things you have to use overclocked CPU table.

Since we overclocked our CPU we need to modify our .c file with all theese tables furter (acpuclock-8x50.c in my case) to match new changes. Search for:

case 0x00:
max_acpu_khz = 998400;

and set it to 1305600 (maximum available CPU freq.)

Then searching for this:

static struct cpufreq_frequency_table freq_table[20];

and changing the value in the ind to 28 since we have now 28 CPU freq. steps in total. That's all for CPU overclock. Continuing boosting our Adreno..

Open your board-****.c file.

If you use old KGSL drivers (Android 2.3 and older), search for struct kgsl_platform_data kgsl_pdata function. In function structure you will see this:

.high_axi_3d = 128000,
.max_grp3d_freq = 0,
.min_grp3d_freq = 0,

Set high_axi_3d value to

192000

.

Set max_grp3d_freq value to

256*1000*1000

.

Set min_grp3d_freq value to

192*1000*1000

.

If you use new KGSL drivers (Android 4.0+) then search for struct kgsl_device_platform_data kgsl_3d0_pdata. You will see something like this:

.pwrlevel = {
{
.gpu_freq = 0,
.bus_freq = 128000000,
},

Set gpu_freq value to

256000000

.

Set bus_freq value to

192000000

.

In the end we have undervolted and overclocked (1.3Ghz) CPU and overclocked GPU of my old phone. Saying again..Overclocking bus higher than 192Khz is realy bad idea for QSD8x50.

When you're done, build your kernel with enabled debugging (CONFIG_DEBUG_KERNEL=y) and then add this script to mount debug sysfs dir. in init.d or anywhere else on auostart:

#!/system/bin/sh
### FeraLab ###
mount -t debugfs debugfs /sys/kernel/debug
echo 0 > /sys/kernel/debug/msm_fb/0/vsync_enable

This script will also disable VSYNC to boost your 2D FPS. When system runs check out /sys/kernel/debug/clk_rate folder (If you can't see this folder the your init.d support is not working properly..put script somewhere else, in /etc/hw_config.sh for ex.). You will have to see reports:

gp_clk - 192000000

grp_3d_clk - 256000000

imem_clk - 256000000

And for CPU overclocking use any app you like from market. No-frill-CPU is a good one.

Bingo! :silly:

Now I can play such games like NFS MW or GTA Vice City on my retired but rocking phone.. (proof video)

If you like this - feed me :good:

Display panel overclocking:

Still not enough? Wow..you're d thirsty one..

Ok.. Let's overclock your LCD bus frequency then.. :eek:

Install any app on you pc that could recursively search txt from kernel directory (I use double-cmd-gtk on ubuntu) or just search you git repo online. Fins this thing (It may vary on 3.x kernels. This is for 2.6 ones):

panel_info.clk_rate

This part of code will most probably be under /drivers/video/msm folder or directly in your board-xxx.c file which is just my case.

I have this values by default:

panel_data->panel_info.clk_rate = 192000000;
panel_data->panel_info.clk_min = 190000000;
panel_data->panel_info.clk_max = 200000000;

Simply change to

panel_data->panel_info.clk_rate = 235000000;
panel_data->panel_info.clk_min = 192000000;
panel_data->panel_info.clk_max = 256000000;

Done :good:

Updating KGSL drivers in kernel:

At first I though this is realy hard to do but I dealed with this and wanna show you a quick and easy way to do it. It is pretty same for most kernel versions. I will do an example using my 2.6 kernel.

Basicly, just get my sourcecode .zip, extract it somewhere. Go to your kernel's /drivers/gpu/msm (or drivers/char/msm) folder and delete it. Now go to my kernel/drivers/gpu/msm and copy that folder to your kernel. Not finished yet. Replace your file with mine from my kernel/include/linux/msm_kgsl.h. Done. Yeah. Soo simple. This are latest CAF gb_release KGSL drivers which improved my 3D performance around 30%. Don't forget to update ROM libs. (You may take them from my .zip too) Same thing is for newer android versions, but dont copy it from my kernel. My kernel is for GingerBread atm.

Tuning Adreno GPU:

This is more simple than previos guides and is already familiar, but I will stick it here again anyway.

It's about using Adreno config file. This will work only on GingerBread ROMs. To make it working place this part of code in your /system/etc/hw_config.sh:

if [ ! -h /data/local/tmp/adreno_config.txt ]; then
chmod 777 /system/etc/adreno_config.txt
ln -s /system/etc/adreno_config.txt /data/local/tmp/adreno_config.txt
fi

Now edit and put your adreno_config.txt in /system/etc/ and set all permissions for it (chmod 777). Also edit your build.prop, add:

debug.egl.hw=1
debug.egl.profiler=1
debug.performance.tuning=1
debug.sf.hw=1

This is how originnal version of adreno_config file looks like. It contains various explanations and I will put it here so you could refer to.

Now what parameters are realy cool to tune are:

forceAutoTextureCompression=1
triJuice=3

Theese configs have to greatly improve your 3D performance in cost of quality, but I think it doesnt matter anymore for old devices.

Juice it:

A simple trick to disable framebuffer swapping and flush all frames without filtering os to edit your build.prop and add/replace theese strings:

debug.sf.hw=1
debug.egl.hw=1
debug.egl.profiler=1
debug.performance.tuning=1
debug.gr.swapinterval=0
debug.egl.swapinterval=0

This will double your 2D FPS but you will get UI glithces instead. It's not because something've get slow - it's because it've get too fast :D. If you wish to use this trick for prolonged use, I suggest you do disable all animations in system settings.

Probably you may want have a look at another my thread for optimized apps & games HERE.

I think that's it for now. Have a nice day-time. Peace out! :fingers-crossed:

[YOUTUBE]950lU5hWGWo[/YOUTUBE]​