[AML] Be rid of damned cpu type magic numbers
authorTrent Nelson <trent.nelson@pivosgroup.com>
Tue, 15 Jul 2014 09:40:18 +0000 (17:40 +0800)
committerTrent Nelson <trent.nelson@pivosgroup.com>
Fri, 18 Jul 2014 03:23:50 +0000 (11:23 +0800)
xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp
xbmc/utils/AMLUtils.cpp
xbmc/utils/AMLUtils.h

index 3a5cc97..36efc67 100644 (file)
@@ -1580,7 +1580,7 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints)
         am_private->gcodec.param = (void*)(EXTERNAL_PTS | SYNC_OUTSIDE);
       break;
     case VFORMAT_H264_4K2K:
-      if (aml_get_cputype() >= 8) {
+      if (aml_get_cputype() >= AML_DEVICE_TYPE_M8) {
         am_private->gcodec.format = VIDEO_DEC_FORMAT_H264_4K2K;
         am_private->gcodec.param  = (void*)EXTERNAL_PTS;
         // h264 in an avi file
index 99af622..80cd61c 100644 (file)
@@ -28,6 +28,7 @@
 #include "utils/CPUInfo.h"
 #include "utils/log.h"
 #include "utils/StringUtils.h"
+#include "utils/AMLUtils.h"
 
 int aml_set_sysfs_str(const char *path, const char *val)
 {
@@ -156,23 +157,23 @@ void aml_permissions()
   }
 }
 
-int aml_get_cputype()
+enum AML_DEVICE_TYPE aml_get_cputype()
 {
-  static int aml_cputype = -1;
-  if (aml_cputype == -1)
+  static enum AML_DEVICE_TYPE aml_cputype = AML_DEVICE_TYPE_UNKNOWN;
+  if (aml_cputype == AML_DEVICE_TYPE_UNKNOWN)
   {
     std::string cpu_hardware = g_cpuInfo.getCPUHardware();
 
     // default to AMLogic M1
-    aml_cputype = 1;
+    aml_cputype = AML_DEVICE_TYPE_M1;
     if (cpu_hardware.find("MESON-M3") != std::string::npos)
-      aml_cputype = 3;
+      aml_cputype = AML_DEVICE_TYPE_M3;
     else if (cpu_hardware.find("MESON3") != std::string::npos)
-      aml_cputype = 3;
+      aml_cputype = AML_DEVICE_TYPE_M3;
     else if (cpu_hardware.find("Meson6") != std::string::npos)
-      aml_cputype = 6;
+      aml_cputype = AML_DEVICE_TYPE_M6;
     else if (cpu_hardware.find("Meson8") != std::string::npos)
-      aml_cputype = 8;
+      aml_cputype = AML_DEVICE_TYPE_M8;
   }
 
   return aml_cputype;
@@ -183,7 +184,7 @@ 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)
+  if (aml_get_cputype() <= AML_DEVICE_TYPE_M3)
   {
     int cpufreq = 300000;
     if (limit)
@@ -196,7 +197,7 @@ void aml_cpufreq_min(bool limit)
 
 void aml_cpufreq_max(bool limit)
 {
-  if (!aml_wired_present() && aml_get_cputype() > 3)
+  if (!aml_wired_present() && aml_get_cputype() > AML_DEVICE_TYPE_M3)
   {
     // this is a MX Stick, they cannot substain 1GHz
     // operation without overheating so limit them to 800MHz.
@@ -214,7 +215,7 @@ 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;
+    int raw = aml_get_cputype() < AML_DEVICE_TYPE_M3 ? 1:2;
     aml_set_sysfs_int("/sys/class/audiodsp/digital_raw", passthrough ? raw:0);
   }
 }
index 2d000b3..b80aa09 100644 (file)
  *
  */
 
+enum AML_DEVICE_TYPE
+{
+  AML_DEVICE_TYPE_UNKNOWN  = -1,
+  AML_DEVICE_TYPE_M1,
+  AML_DEVICE_TYPE_M3,
+  AML_DEVICE_TYPE_M6,
+  AML_DEVICE_TYPE_M8
+};
+
 int aml_set_sysfs_str(const char *path, const char *val);
 int aml_get_sysfs_str(const char *path, char *valstr, const int size);
 int aml_set_sysfs_int(const char *path, const int val);
@@ -28,7 +37,7 @@ bool aml_present();
 void aml_permissions();
 bool aml_hw3d_present();
 bool aml_wired_present();
-int  aml_get_cputype();
+enum AML_DEVICE_TYPE aml_get_cputype();
 void aml_cpufreq_min(bool limit);
 void aml_cpufreq_max(bool limit);
 void aml_set_audio_passthrough(bool passthrough);