From 5989f1b19c15c0c1b88f6cf7f46e72ad35aaf54e Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Tue, 15 Jul 2014 17:40:18 +0800 Subject: [PATCH] [AML] Be rid of damned cpu type magic numbers --- xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp | 2 +- xbmc/utils/AMLUtils.cpp | 23 ++++++++++++----------- xbmc/utils/AMLUtils.h | 11 ++++++++++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp index 3a5cc97..36efc67 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_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 diff --git a/xbmc/utils/AMLUtils.cpp b/xbmc/utils/AMLUtils.cpp index 99af622..80cd61c 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,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); } } diff --git a/xbmc/utils/AMLUtils.h b/xbmc/utils/AMLUtils.h index 2d000b3..b80aa09 100644 --- a/xbmc/utils/AMLUtils.h +++ b/xbmc/utils/AMLUtils.h @@ -19,6 +19,15 @@ * */ +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); -- 2.7.4