Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
arpruss
Old
(Last edited by arpruss; 15th July 2011 at 04:21 AM.)
#1  
Senior Member - OP
Thanks Meter 274
Posts: 662
Join Date: Jul 2010

 
DONATE TO ME
Default Fix for lowered max CPU rate in media players

I was playing around with adjusting and monitoring the CPU rate on my A43, and I discovered an oddity. I have the device set to overdrive, so normally it can do 1ghz. But I noticed that inside Netflix's video player (not just the Netflix app, the video player), the CPU speed was only 800mhz and there was some stuttering. Looking more carefully, I noticed that somehow as soon as the video player started up, the maximum scaling frequency went down to 800mhz. Exit, and it goes back to 1ghz. I then found that the same happens in Youtube and the Archos Video player.

How annoying, though maybe there is some good reason for it? Is it perhaps that the video hardware can't handle the greater speed? Does anybody know?

Anyway, I have a simple fix: You just have to turn off the write permissions on /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq after the values have been all set. I don't know if any of the CPU speed utilities like SetCPU let you do this.

I fix this by setting my CPU speed settings via a script that runs on boot. (I run it via a tiny utility I wrote which I am not presently releasing, but you could also run it via Script Manager.) The script I use is:
Code:
cd /sys/devices/system/cpu/cpu0/cpufreq
echo conservative > scaling_governor
chmod 644 scaling_max_freq
echo 1000000 > scaling_max_freq
chmod 444 scaling_max_freq
echo 300000 > scaling_min_freq
echo 150000 > conservative/sampling_rate
echo 70 > conservative/up_threshold
The crucial line is the "chmod 444 scaling_max_freq" which sets the scaling_max_freq file to read-only. (Of course, a determined app that wants to change it can just chmod 644 scaling_max_freq and write to it. But whatever is doing the switch 800mhz isn't THAT determined.)

The result is that Star Trek plays smoothly at 1ghz in Netflix, as it should, while the built-in video player when playing lower-resolution videos uses 800mhz, as it also should.

If you have a device with a higher top speed than 1000000, just change the 1000000 to whatever your top speed is.

If you want to check if your device has the issue, start up a video, and then while the video is playing, do:
Code:
adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
If it's less than the top speed of your device, you have the issue.

But maybe it's supposed to be like that?
The Following User Says Thank You to arpruss For This Useful Post: [ Click to Expand ]
 
wokker666
Old
(Last edited by wokker666; 16th July 2011 at 05:07 AM.) Reason: Learning
#2  
wokker666's Avatar
Member
Thanks Meter 15
Posts: 55
Join Date: Jun 2011
Location: Detroit
Quote:
Originally Posted by arpruss View Post
The script I use is:
Code:
cd /sys/devices/system/cpu/cpu0/cpufreq
echo conservative > scaling_governor
chmod 644 scaling_max_freq
echo 1000000 > scaling_max_freq
chmod 444 scaling_max_freq
echo 300000 > scaling_min_freq
echo 150000 > conservative/sampling_rate
echo 70 > conservative/up_threshold
Would I run this script verbatim for interactive mode? Or change 'conservative' in the script to 'interactive'?

EDIT I think I get it...... gonna play for a bit....
_____________________
HTC Dream / CM6

Samsung Galaxy S III 16GB / Stock Jellybean

Archos A101IT 8GB / SDE: Stock 2.4.80 / UrukDroid 1.5

Acer Iconia A500 16GB / kjy2010 Honeylicious HC 3.2
 
arpruss
Old
#3  
Senior Member - OP
Thanks Meter 274
Posts: 662
Join Date: Jul 2010

 
DONATE TO ME
I think the stock ROM only supports ondemand, conservative and performance.
 
wokker666
Old
(Last edited by wokker666; 16th July 2011 at 05:30 AM.) Reason: uhh
#4  
wokker666's Avatar
Member
Thanks Meter 15
Posts: 55
Join Date: Jun 2011
Location: Detroit
Quote:
Originally Posted by arpruss View Post
I think the stock ROM only supports ondemand, conservative and performance.
I'm on Uruk 1.0, err, well both, but I dominantly run on Uruk
_____________________
HTC Dream / CM6

Samsung Galaxy S III 16GB / Stock Jellybean

Archos A101IT 8GB / SDE: Stock 2.4.80 / UrukDroid 1.5

Acer Iconia A500 16GB / kjy2010 Honeylicious HC 3.2
 
arpruss
Old
#5  
Senior Member - OP
Thanks Meter 274
Posts: 662
Join Date: Jul 2010

 
DONATE TO ME
Quote:
Originally Posted by wokker666 View Post
I'm on Uruk 1.0, err, well both, but I dominantly run on Uruk
I see. Then, yes, you do need to change things to set up whatever settings you want for interactive. Are you using any CPU-setting utility? I don't know how well my script will work with a CPU-setting utility. The one I tried automatically set read/write permissions to the files, which undoes the effects of my script.
 
wokker666
Old
#6  
wokker666's Avatar
Member
Thanks Meter 15
Posts: 55
Join Date: Jun 2011
Location: Detroit
I think I got it

I can confirm that SetCPU does reset the permissions, killing SU permissions to the app seems to fix that

I remade the script to go a little something like...

Code:
cd /sys/devices/system/cpu/cpu0/cpufreq
echo interactive > scaling_governor
chmod 644 scaling_max_freq
echo 1000000 > scaling_max_freq
chmod 444 scaling_max_freq
chmod 644 scaling_min_freq
echo 600000 > scaling_min_freq
chmod 444 scaling_min_freq
The scaling_min_freq part may seem useless, but it further sets what you want in stone

So far after a few reboots, everything seems to be working just fine, and the system dosen't scale the cpu to 800000 when in video!

Nice!

Thanks!
_____________________
HTC Dream / CM6

Samsung Galaxy S III 16GB / Stock Jellybean

Archos A101IT 8GB / SDE: Stock 2.4.80 / UrukDroid 1.5

Acer Iconia A500 16GB / kjy2010 Honeylicious HC 3.2
 
arpruss
Old
#7  
Senior Member - OP
Thanks Meter 274
Posts: 662
Join Date: Jul 2010

 
DONATE TO ME
Any idea WHY Archos did that 800mhz scaling?

Maybe it's just a bug. I think they initially wanted the device to run at 800MHz, and then later added an Overdrive mode at 1000. So the 800 could be a leftover, no?
 
wokker666
Old
#8  
wokker666's Avatar
Member
Thanks Meter 15
Posts: 55
Join Date: Jun 2011
Location: Detroit
Quote:
Originally Posted by arpruss View Post
Any idea WHY Archos did that 800mhz scaling?

Maybe it's just a bug. I think they initially wanted the device to run at 800MHz, and then later added an Overdrive mode at 1000. So the 800 could be a leftover, no?
I think they did it to help conserve the battery, if you use your unit for mostly video, it would make sense to not burn through your battery at 1ghz...

On that note, my system with the settings I just made, in video it REALLY scales to my settings.... it dominantly runs at 600mhz, not 1ghz - maybe it's the interactive mode kicking in, it just dosent see the demand - I can't test in real time right now though, no linux machine as of yet, but time in state shows mostly 600mhz, and some 1ghz
_____________________
HTC Dream / CM6

Samsung Galaxy S III 16GB / Stock Jellybean

Archos A101IT 8GB / SDE: Stock 2.4.80 / UrukDroid 1.5

Acer Iconia A500 16GB / kjy2010 Honeylicious HC 3.2
 
arpruss
Old
#9  
Senior Member - OP
Thanks Meter 274
Posts: 662
Join Date: Jul 2010

 
DONATE TO ME
Quote:
Originally Posted by wokker666 View Post
I think they did it to help conserve the battery, if you use your unit for mostly video, it would make sense to not burn through your battery at 1ghz...
But that's what the scaling is for. When the video doesn't need the higher speed, it scales it down, and when it needs it, it scales it up. Star Trek on Netflix needs 1000, while different xvid videos that I have need different speeds.

By the way, I noticed that they also set scaling_min_freq to 800 in the video player. So, my script also needs a line:
Code:
chmod 444 scaling_min_freq
at the end.
 
wokker666
Old
#10  
wokker666's Avatar
Member
Thanks Meter 15
Posts: 55
Join Date: Jun 2011
Location: Detroit
Quote:
Originally Posted by arpruss View Post
But that's what the scaling is for. When the video doesn't need the higher speed, it scales it down, and when it needs it, it scales it up. Star Trek on Netflix needs 1000, while different xvid videos that I have need different speeds.
Most of what I was testing are .mkv's of all sorts of flavors, they probably dont need to bump up the speed - I should find a hd vid to test with.

Quote:
By the way, I noticed that they also set scaling_min_freq to 800 in the video player. So, my script also needs a line:
Code:
chmod 444 scaling_min_freq
at the end.
I knew I threw that in for a reason
_____________________
HTC Dream / CM6

Samsung Galaxy S III 16GB / Stock Jellybean

Archos A101IT 8GB / SDE: Stock 2.4.80 / UrukDroid 1.5

Acer Iconia A500 16GB / kjy2010 Honeylicious HC 3.2

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

report this ad
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Learn to Edit Graphics for your Development Work

The importance of good and appropriate graphics for your development work is undeniable. Be … more

Tasker Alternative: AutomateIt, Automates Your Device Tasks – XDA Developer TV

XDA Developer TV Producer Kevin wants to help make your … more

Preventing App Piracy: Join the Discussion

The topic of piracy is always a touchy subject, but I feel that the grass roots style of Android … more

Jolla Sailfish OS Flagship Device Makes First Appearance

Given the amount of coverage that Android receives around here, you could almost be … more