提交 09e66ada 编写于 作者: A Alexander Smorkalov

New Tegra detector with Android 4.3 support added. Manager version++.

(cherry picked from commit aa00b5a0)

Conflicts:

	platforms/android/service/engine/jni/BinderComponent/TegraDetector.cpp
上级 ba26f6d4
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine"
android:versionCode="29@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.9" >
android:versionCode="210@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.10" >
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
......
......@@ -26,19 +26,32 @@ endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/platforms/android/service/engine/.build/${ANDROID_MANIFEST_FILE}" @ONLY)
link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib" "${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib" "${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}")
link_directories(
"${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib"
"${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib"
"${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}")
file(GLOB engine_files "jni/BinderComponent/*.cpp" "jni/BinderComponent/*.h" "jni/include/*.h")
set(engine_libs "z" "binder" "log" "utils")
if (TEGRA_DETECTOR)
if (ANDROID_NATIVE_API_LEVEL GREATER 8)
add_definitions(-DUSE_TEGRA_HW_DETECTOR)
list(APPEND engine_libs ${TEGRA_DETECTOR} GLESv2 EGL)
else()
message(FATAL_ERROR "Tegra detector required native api level 9 or above")
endif()
endif()
# -D__SUPPORT_ARMEABI_FEATURES key is also available
add_definitions(-DPLATFORM_ANDROID -D__SUPPORT_ARMEABI_V7A_FEATURES -D__SUPPORT_TEGRA3 -D__SUPPORT_MIPS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
file(GLOB engine_files "jni/BinderComponent/*.cpp" "jni/BinderComponent/*.h" "jni/include/*.h")
include_directories(jni/BinderComponent jni/include)
include_directories("jni/BinderComponent" "jni/include")
include_directories(SYSTEM "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/system/core/include")
add_library(${engine} SHARED ${engine_files})
target_link_libraries(${engine} z binder log utils)
target_link_libraries(${engine} ${engine_libs})
set_target_properties(${engine} PROPERTIES
OUTPUT_NAME ${engine}
......@@ -51,7 +64,15 @@ add_custom_command(TARGET ${engine} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-un
file(GLOB engine_jni_files "jni/JNIWrapper/*.cpp" "jni/JNIWrapper/*.h" "jni/include/*.h")
list(APPEND engine_jni_files jni/NativeService/CommonPackageManager.cpp jni/NativeService/PackageInfo.cpp)
include_directories(jni/include jni/JNIWrapper jni/NativeService jni/BinderComponent "${ANDROID_SOURCE_TREE}/frameworks/base/include" "${ANDROID_SOURCE_TREE}/system/core/include" "${ANDROID_SOURCE_TREE}/frameworks/base/core/jni")
include_directories(
jni/include jni/JNIWrapper
jni/NativeService
jni/BinderComponent
"${ANDROID_SOURCE_TREE}/frameworks/base/include"
"${ANDROID_SOURCE_TREE}/system/core/include"
"${ANDROID_SOURCE_TREE}/frameworks/base/core/jni"
)
add_library(${engine}_jni SHARED ${engine_jni_files})
target_link_libraries(${engine}_jni z binder log utils android_runtime ${engine})
......
......@@ -13,7 +13,7 @@ int GetCpuID()
map<string, string> cpu_info = GetCpuInfo();
map<string, string>::const_iterator it;
#if defined(__i386__)
#if defined(__i386__)
LOGD("Using X86 HW detector");
result |= ARCH_X86;
it = cpu_info.find("flags");
......@@ -161,8 +161,11 @@ int GetProcessorCount()
int DetectKnownPlatforms()
{
#if defined(__arm__) && defined(USE_TEGRA_HW_DETECTOR)
int tegra_status = DetectTegra();
#else
int tegra_status = NOT_TEGRA;
#endif
// All Tegra platforms since Tegra3
if (2 < tegra_status)
{
......@@ -172,4 +175,4 @@ int DetectKnownPlatforms()
{
return PLATFORM_UNKNOWN;
}
}
\ No newline at end of file
}
#include "TegraDetector.h"
#include <zlib.h>
#include <string.h>
#define KERNEL_CONFIG "/proc/config.gz"
#define KERNEL_CONFIG_MAX_LINE_WIDTH 512
#define KERNEL_CONFIG_TEGRA_MAGIC "CONFIG_ARCH_TEGRA=y"
#define KERNEL_CONFIG_TEGRA2_MAGIC "CONFIG_ARCH_TEGRA_2x_SOC=y"
#define KERNEL_CONFIG_TEGRA3_MAGIC "CONFIG_ARCH_TEGRA_3x_SOC=y"
#define KERNEL_CONFIG_TEGRA4_MAGIC "CONFIG_ARCH_TEGRA_11x_SOC=y"
#define MAX_DATA_LEN 4096
int DetectTegra()
{
int result = TEGRA_NOT_TEGRA;
gzFile kernelConfig = gzopen(KERNEL_CONFIG, "r");
if (kernelConfig != 0)
{
char tmpbuf[KERNEL_CONFIG_MAX_LINE_WIDTH];
const char *tegra_config = KERNEL_CONFIG_TEGRA_MAGIC;
const char *tegra2_config = KERNEL_CONFIG_TEGRA2_MAGIC;
const char *tegra3_config = KERNEL_CONFIG_TEGRA3_MAGIC;
const char *tegra4_config = KERNEL_CONFIG_TEGRA4_MAGIC;
int len = strlen(tegra_config);
int len2 = strlen(tegra2_config);
int len3 = strlen(tegra3_config);
int len4 = strlen(tegra4_config);
while (0 != gzgets(kernelConfig, tmpbuf, KERNEL_CONFIG_MAX_LINE_WIDTH))
{
if (0 == strncmp(tmpbuf, tegra_config, len))
{
result = 1;
}
if (0 == strncmp(tmpbuf, tegra2_config, len2))
{
result = 2;
break;
}
if (0 == strncmp(tmpbuf, tegra3_config, len3))
{
result = 3;
break;
}
if (0 == strncmp(tmpbuf, tegra4_config, len4))
{
result = 4;
break;
}
}
gzclose(kernelConfig);
}
else
{
result = TEGRA_DETECTOR_ERROR;
}
return result;
}
\ No newline at end of file
......@@ -2,8 +2,13 @@
#define __TEGRA_DETECTOR_H__
#define TEGRA_DETECTOR_ERROR -2
#define TEGRA_NOT_TEGRA -1
#define NOT_TEGRA -1
#define TEGRA2 2
#define TEGRA3 3
#define TEGRA4i 4
#define TEGRA4 5
#define TEGRA5 6
int DetectTegra();
#endif
\ No newline at end of file
#endif
......@@ -30,11 +30,12 @@ public class HardwareDetector
// GPU Acceleration options
public static final int FEATURES_HAS_GPU = 0x010000;
public static final int PLATFORM_TEGRA = 1;
public static final int PLATFORM_TEGRA2 = 2;
public static final int PLATFORM_TEGRA3 = 3;
public static final int PLATFORM_TEGRA4 = 4;
public static final int PLATFORM_TEGRA = 1;
public static final int PLATFORM_TEGRA2 = 2;
public static final int PLATFORM_TEGRA3 = 3;
public static final int PLATFORM_TEGRA4i = 4;
public static final int PLATFORM_TEGRA4 = 5;
public static final int PLATFORM_TEGRA5 = 6;
public static final int PLATFORM_UNKNOWN = 0;
......
......@@ -107,6 +107,10 @@ public class ManagerActivity extends Activity
{
HardwarePlatformView.setText("Tegra 3");
}
else if (HardwareDetector.PLATFORM_TEGRA4i == Platfrom)
{
HardwarePlatformView.setText("Tegra 4i");
}
else
{
HardwarePlatformView.setText("Tegra 4");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册