diff options
author | Trent Nelson <trent.nelson@pivosgroup.com> | 2014-07-18 17:30:56 +0800 |
---|---|---|
committer | Trent Nelson <trent.nelson@pivosgroup.com> | 2014-07-18 17:30:56 +0800 |
commit | c7e84593e79a07a087db075057543d6ad4c69ee9 (patch) | |
tree | 0e689266d71713b1d530964b88694329b764b84f | |
parent | 05ca69a2b1c4448278e72ecae3f2c718c8f1dce8 (diff) | |
parent | e442accf05cdafab561fb442fabf654e5af65cc0 (diff) |
Merge pull request #5035 from t-nelson/aml_cpu_enumify
[AML] Be rid of damned cpu type magic numbers
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp | 2 | ||||
-rw-r--r-- | xbmc/utils/AMLUtils.cpp | 37 | ||||
-rw-r--r-- | xbmc/utils/AMLUtils.h | 12 |
3 files changed, 33 insertions, 18 deletions
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp index 3a5cc97629..54ab39f9de 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp @@ -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_device_type() == 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 diff --git a/xbmc/utils/AMLUtils.cpp b/xbmc/utils/AMLUtils.cpp index 99af62220b..8a622afa62 100644 --- a/xbmc/utils/AMLUtils.cpp +++ b/xbmc/utils/AMLUtils.cpp @@ -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,26 +157,27 @@ void aml_permissions() } } -int aml_get_cputype() +enum AML_DEVICE_TYPE aml_get_device_type() { - static int aml_cputype = -1; - if (aml_cputype == -1) + static enum AML_DEVICE_TYPE aml_device_type = AML_DEVICE_TYPE_UNINIT; + if (aml_device_type == AML_DEVICE_TYPE_UNINIT) { std::string cpu_hardware = g_cpuInfo.getCPUHardware(); - // default to AMLogic M1 - aml_cputype = 1; - if (cpu_hardware.find("MESON-M3") != std::string::npos) - aml_cputype = 3; - else if (cpu_hardware.find("MESON3") != std::string::npos) - aml_cputype = 3; + if (cpu_hardware.find("MESON-M1") != std::string::npos) + aml_device_type = AML_DEVICE_TYPE_M1; + else if (cpu_hardware.find("MESON-M3") != std::string::npos + || cpu_hardware.find("MESON3") != std::string::npos) + aml_device_type = AML_DEVICE_TYPE_M3; else if (cpu_hardware.find("Meson6") != std::string::npos) - aml_cputype = 6; + aml_device_type = AML_DEVICE_TYPE_M6; else if (cpu_hardware.find("Meson8") != std::string::npos) - aml_cputype = 8; + aml_device_type = AML_DEVICE_TYPE_M8; + else + aml_device_type = AML_DEVICE_TYPE_UNKNOWN; } - return aml_cputype; + return aml_device_type; } void aml_cpufreq_min(bool limit) @@ -183,7 +185,8 @@ 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_device_type() != AML_DEVICE_TYPE_UNKNOWN + && aml_get_device_type() <= AML_DEVICE_TYPE_M3) { int cpufreq = 300000; if (limit) @@ -196,7 +199,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_device_type() == AML_DEVICE_TYPE_M6) { // this is a MX Stick, they cannot substain 1GHz // operation without overheating so limit them to 800MHz. @@ -211,10 +214,12 @@ void aml_cpufreq_max(bool limit) void aml_set_audio_passthrough(bool passthrough) { - if (aml_present()) + if ( aml_present() + && aml_get_device_type() != AML_DEVICE_TYPE_UNKNOWN + && aml_get_device_type() <= AML_DEVICE_TYPE_M8) { // m1 uses 1, m3 and above uses 2 - int raw = aml_get_cputype() < 3 ? 1:2; + int raw = aml_get_device_type() == AML_DEVICE_TYPE_M1 ? 1:2; aml_set_sysfs_int("/sys/class/audiodsp/digital_raw", passthrough ? raw:0); } } diff --git a/xbmc/utils/AMLUtils.h b/xbmc/utils/AMLUtils.h index 2d000b3b78..aa0e3e92d2 100644 --- a/xbmc/utils/AMLUtils.h +++ b/xbmc/utils/AMLUtils.h @@ -19,6 +19,16 @@ * */ +enum AML_DEVICE_TYPE +{ + AML_DEVICE_TYPE_UNINIT = -2, + 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 +38,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_device_type(); void aml_cpufreq_min(bool limit); void aml_cpufreq_max(bool limit); void aml_set_audio_passthrough(bool passthrough); |