summaryrefslogtreecommitdiffstats
path: root/GNexusParts
diff options
context:
space:
mode:
authorhumberos <humberos@gmail.com>2012-09-06 09:16:29 -0300
committerhumberos <humberos@gmail.com>2012-09-10 19:53:38 -0300
commit42356b75fc74a2a7b38349a99a83c212d8a94f96 (patch)
tree786c8be2ddeaa6103be78422eb2ea83c8eb7627f /GNexusParts
parent07acde36832b05b013e40d4e7f75d2d563cdd88d (diff)
downloaddevice_samsung_tuna-42356b75fc74a2a7b38349a99a83c212d8a94f96.zip
device_samsung_tuna-42356b75fc74a2a7b38349a99a83c212d8a94f96.tar.gz
device_samsung_tuna-42356b75fc74a2a7b38349a99a83c212d8a94f96.tar.bz2
Add GPU@OC support change by sysfs
Change-Id: I0e56cffb24dedf184339694094fe5ab602b3b939
Diffstat (limited to 'GNexusParts')
-rw-r--r--GNexusParts/AndroidManifest.xml1
-rw-r--r--GNexusParts/res/values/arrays.xml13
-rw-r--r--GNexusParts/res/values/strings.xml4
-rw-r--r--GNexusParts/res/xml/overclock_preferences.xml11
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java3
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/GpuOverclock.java61
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/OverClockFragmentActivity.java58
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/Startup.java1
8 files changed, 152 insertions, 0 deletions
diff --git a/GNexusParts/AndroidManifest.xml b/GNexusParts/AndroidManifest.xml
index 12b1009..e8994c1 100644
--- a/GNexusParts/AndroidManifest.xml
+++ b/GNexusParts/AndroidManifest.xml
@@ -26,6 +26,7 @@
<activity android:name=".GeneralFragmentActivity" />
<activity android:name=".DisplayFragmentActivity" />
<activity android:name=".SoundFragmentActivity" />
+ <activity android:name=".OverClockFragmentActivity" />
</application>
</manifest>
diff --git a/GNexusParts/res/values/arrays.xml b/GNexusParts/res/values/arrays.xml
new file mode 100644
index 0000000..9dc3111
--- /dev/null
+++ b/GNexusParts/res/values/arrays.xml
@@ -0,0 +1,13 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="gpu_overclock_entries">
+ <item>307,2 MHz (default)</item>
+ <item>384,0 MHz</item>
+ <item>512,0 MHz</item>
+ </string-array>
+
+ <string-array name="gpu_overclock_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+</resources>
diff --git a/GNexusParts/res/values/strings.xml b/GNexusParts/res/values/strings.xml
index 5bc261d..01902a5 100644
--- a/GNexusParts/res/values/strings.xml
+++ b/GNexusParts/res/values/strings.xml
@@ -48,4 +48,8 @@
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Enable HSDPA/HSUPA</string>
+ <string name="category_speed_title">GPU</string>
+ <string name="category_gpu_title">GPU</string>
+ <string name="gpu_overclock_title">Clock Speed</string>
+
</resources>
diff --git a/GNexusParts/res/xml/overclock_preferences.xml b/GNexusParts/res/xml/overclock_preferences.xml
new file mode 100644
index 0000000..551275b
--- /dev/null
+++ b/GNexusParts/res/xml/overclock_preferences.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <ListPreference
+ android:key="gpu_overclock"
+ android:title="@string/gpu_overclock_title"
+ android:entries="@array/gpu_overclock_entries"
+ android:entryValues="@array/gpu_overclock_values"
+ android:defaultValue="0" />
+
+</PreferenceScreen>
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java b/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
index 3499565..93e271d 100644
--- a/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -46,6 +46,7 @@ public class DeviceSettings extends Activity {
public static final String KEY_VIBRATOR_TUNING = "vibrator_tuning";
public static final String KEY_CATEGORY_RADIO = "category_radio";
public static final String KEY_HSPA = "hspa";
+ public static final String KEY_GPU_OVERCLOCK = "gpu_overclock";
ViewPager mViewPager;
TabsAdapter mTabsAdapter;
@@ -68,6 +69,8 @@ public class DeviceSettings extends Activity {
DisplayFragmentActivity.class, null);
mTabsAdapter.addTab(bar.newTab().setText(R.string.general_title),
GeneralFragmentActivity.class, null);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.category_speed_title),
+ OverClockFragmentActivity.class, null);
if (savedInstanceState != null) {
bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/GpuOverclock.java b/GNexusParts/src/com/cyanogenmod/settings/device/GpuOverclock.java
new file mode 100644
index 0000000..63a1514
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/GpuOverclock.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class GpuOverclock implements OnPreferenceChangeListener {
+
+ private static final String FILE = "/sys/devices/system/cpu/cpu0/cpufreq/gpu_oc";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_GPU_OVERCLOCK, "0"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ updateSummary((ListPreference) preference, Integer.parseInt(newValue.toString()));
+ return true;
+ }
+
+ public static void updateSummary(ListPreference preference, int value) {
+ final CharSequence[] entries = preference.getEntries();
+ final CharSequence[] values = preference.getEntryValues();
+ int best = 0;
+ for (int i = 0; i < values.length; i++) {
+ int summaryValue = Integer.parseInt(values[i].toString());
+ if (value >= summaryValue) {
+ best = i;
+ }
+ }
+ preference.setSummary(entries[best].toString());
+ }
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/OverClockFragmentActivity.java b/GNexusParts/src/com/cyanogenmod/settings/device/OverClockFragmentActivity.java
new file mode 100644
index 0000000..66be07b
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/OverClockFragmentActivity.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.cyanogenmod.settings.device.R;
+
+public class OverClockFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GNexParts_OverClock";
+
+ private ListPreference mGpuOverclock;
+ private ListPreference mTouchscreenClock;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.overclock_preferences);
+
+ PreferenceScreen prefSet = getPreferenceScreen();
+
+ mGpuOverclock = (ListPreference) findPreference(DeviceSettings.KEY_GPU_OVERCLOCK);
+ mGpuOverclock.setEnabled(GpuOverclock.isSupported());
+ mGpuOverclock.setOnPreferenceChangeListener(new GpuOverclock());
+ GpuOverclock.updateSummary(mGpuOverclock, Integer.parseInt(mGpuOverclock.getValue()));
+
+ }
+
+ public static void restore(Context context) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ }
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/Startup.java b/GNexusParts/src/com/cyanogenmod/settings/device/Startup.java
index ba4aeee..8cca2da 100644
--- a/GNexusParts/src/com/cyanogenmod/settings/device/Startup.java
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/Startup.java
@@ -12,6 +12,7 @@ public class Startup extends BroadcastReceiver {
GammaTuningPreference.restore(context);
GeneralFragmentActivity.restore(context);
VibratorTuningPreference.restore(context);
+ GpuOverclock.restore(context);
if (Hspa.isSupported()) {
Hspa.restore(context);
}