Permalink
Browse files

Merge pull request #3593 from t-nelson/pivos_mx_stick_tweaks

Pivos mx stick tweaks
  • Loading branch information...
2 parents 44824bc + f203d9d commit 50bb60cba7425bf7c1ca454bacb8f9f7564e8766 @t-nelson t-nelson committed Nov 11, 2013
View
@@ -97,7 +97,44 @@ bool aml_present()
if (has_aml)
CLog::Log(LOGNOTICE, "aml_present, rtn(%d)", rtn);
}
- return has_aml;
+ return has_aml == 1;
+}
+
+bool aml_wired_present()
+{
+ static int has_wired = -1;
+ if (has_wired == -1)
+ {
+ char test[64] = {0};
+ if (aml_get_sysfs_str("/sys/class/net/eth0/operstate", test, 63) != -1)
+ has_wired = 1;
+ else
+ has_wired = 0;
+ }
+ return has_wired == 1;
+}
+
+void aml_permissions()
+{
+ // most all aml devices are already rooted.
+ int ret = system("ls /system/xbin/su");
+ if (ret != 0)
+ {
+ CLog::Log(LOGWARNING, "aml_permissions: missing su, playback might fail");
+ }
+ else
+ {
+ // certain aml devices have 664 permission, we need 666.
+ system("su -c chmod 666 /sys/class/video/axis");
+ system("su -c chmod 666 /sys/class/video/screen_mode");
+ system("su -c chmod 666 /sys/class/video/disable_video");
+ system("su -c chmod 666 /sys/class/tsync/pts_pcrscr");
+ system("su -c chmod 666 /sys/class/audiodsp/digital_raw");
+ system("su -c chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq");
+ system("su -c chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq");
+ system("su -c chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor");
+ CLog::Log(LOGINFO, "aml_permissions: permissions changed");
+ }
}
int aml_get_cputype()
@@ -120,19 +157,42 @@ int aml_get_cputype()
return aml_cputype;
}
-void aml_cpufreq_limit(bool limit)
+void aml_cpufreq_min(bool limit)
+{
+// do not touch scaling_min_freq on android
+#if !defined(TARGET_ANDROID)
+ // only needed for m1/m3 SoCs
+ if (aml_get_cputype() <= 3)
+ {
+ int cpufreq = 300000;
+ if (limit)
+ cpufreq = 600000;
+
+ aml_set_sysfs_int("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", cpufreq);
+ }
+#endif
+}
+
+void aml_cpufreq_max(bool limit)
{
- int cpufreq = 300000;
- if (limit)
- cpufreq = 600000;
+ if (!aml_wired_present() && aml_get_cputype() > 3)
+ {
+ // this is a MX Stick, they cannot substain 1GHz
+ // operation without overheating so limit them to 800MHz.
+ int cpufreq = 1000000;
+ if (limit)
+ cpufreq = 800000;
- aml_set_sysfs_int("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", cpufreq);
+ aml_set_sysfs_int("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", cpufreq);
+ aml_set_sysfs_str("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "ondemand");
+ }
}
void aml_set_audio_passthrough(bool passthrough)
{
if (aml_present())
{
+ // m1 uses 1, m3 and above uses 2
int raw = aml_get_cputype() < 3 ? 1:2;
aml_set_sysfs_int("/sys/class/audiodsp/digital_raw", passthrough ? raw:0);
}
View
@@ -25,6 +25,9 @@ int aml_set_sysfs_int(const char *path, const int val);
int aml_get_sysfs_int(const char *path);
bool aml_present();
+void aml_permissions();
+bool aml_wired_present();
int aml_get_cputype();
-void aml_cpufreq_limit(bool limit);
+void aml_cpufreq_min(bool limit);
+void aml_cpufreq_max(bool limit);
void aml_set_audio_passthrough(bool passthrough);
@@ -62,12 +62,15 @@ bool CEGLNativeTypeAmlogic::CheckCompatibility()
void CEGLNativeTypeAmlogic::Initialize()
{
- aml_cpufreq_limit(true);
+ aml_permissions();
+ aml_cpufreq_min(true);
+ aml_cpufreq_max(true);
return;
}
void CEGLNativeTypeAmlogic::Destroy()
{
- aml_cpufreq_limit(false);
+ aml_cpufreq_min(false);
+ aml_cpufreq_max(false);
return;
}
@@ -17,14 +17,19 @@
* <http://www.gnu.org/licenses/>.
*
*/
+
#include "system.h"
#include <EGL/egl.h>
#include "EGLNativeTypeAndroid.h"
#include "utils/log.h"
#include "guilib/gui3d.h"
#if defined(TARGET_ANDROID)
-#include "android/activity/XBMCApp.h"
+ #include "android/activity/XBMCApp.h"
+ #if defined(HAS_AMLPLAYER) || defined(HAS_LIBAMCODEC)
+ #include "utils/AMLUtils.h"
+ #endif
#endif
+
CEGLNativeTypeAndroid::CEGLNativeTypeAndroid()
{
}
@@ -43,10 +48,21 @@ bool CEGLNativeTypeAndroid::CheckCompatibility()
void CEGLNativeTypeAndroid::Initialize()
{
+#if defined(TARGET_ANDROID) && (defined(HAS_AMLPLAYER) || defined(HAS_LIBAMCODEC))
+ aml_permissions();
+ aml_cpufreq_min(true);
+ aml_cpufreq_max(true);
+#endif
+
return;
}
void CEGLNativeTypeAndroid::Destroy()
{
+#if defined(TARGET_ANDROID) && (defined(HAS_AMLPLAYER) || defined(HAS_LIBAMCODEC))
+ aml_cpufreq_min(false);
+ aml_cpufreq_max(false);
+#endif
+
return;
}

0 comments on commit 50bb60c

Please sign in to comment.