diff --git a/android/README b/android/README new file mode 100644 index 00000000..a1d3368d --- /dev/null +++ b/android/README @@ -0,0 +1,24 @@ +librtlsdr for Android +===================== + +Building: +--------- + +To build librtlsdr for Android do the following: + + 1. Download the latest NDK from: + http://developer.android.com/tools/sdk/ndk/index.html + + 2. Extract the NDK. + + 3. Open a shell and make sure there exist an NDK global variable + set to the directory where you extracted the NDK. + + 4. Change directory to librtlsdr's "android/jni" + + 5. Set LIBUSB_INCLUDES and LIBUSB_PREBUILDS for proper locations. + + 6. Run "$NDK/ndk-build". + +The librtlsdr library and tools can then be found in: + "android/libs/$ARCH" diff --git a/android/jni/Android.mk b/android/jni/Android.mk new file mode 100644 index 00000000..722869e0 --- /dev/null +++ b/android/jni/Android.mk @@ -0,0 +1,22 @@ +# Android build config for libusb, examples and tests +# Copyright © 2012-2013 RealVNC Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +LOCAL_PATH:= $(call my-dir) + +include $(LOCAL_PATH)/librtlsdr.mk +include $(LOCAL_PATH)/tools.mk diff --git a/android/jni/Application.mk b/android/jni/Application.mk new file mode 100644 index 00000000..03a83487 --- /dev/null +++ b/android/jni/Application.mk @@ -0,0 +1,20 @@ +# Android application build config for libusb +# Copyright © 2012-2013 RealVNC Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +APP_ABI := all +APP_PLATFORM := android-9 diff --git a/android/jni/librtlsdr.mk b/android/jni/librtlsdr.mk new file mode 100644 index 00000000..269b81af --- /dev/null +++ b/android/jni/librtlsdr.mk @@ -0,0 +1,57 @@ +# Android build config for libusb +# Copyright © 2012-2013 RealVNC Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +LOCAL_PATH:= $(call my-dir) +LIBRTLSDR_ROOT_REL:= ../.. +LIBRTLSDR_ROOT_ABS:= $(LOCAL_PATH)/../.. + + +# libusb +include $(CLEAR_VARS) + +LOCAL_MODULE := libusb + +LOCAL_SRC_FILES := $(LIBUSB_PREBUILDS)/$(TARGET_ARCH_ABI)/libusb1.0.so + +LOCAL_EXPORT_C_INCLUDES := \ + $(LIBUSB_INCLUDES)/libusb \ + +include $(PREBUILT_SHARED_LIBRARY) + + +# librtlsdr +include $(CLEAR_VARS) + +LOCAL_MODULE := librtlsdr + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/librtlsdr.c \ + $(LIBRTLSDR_ROOT_REL)/src/tuner_e4k.c \ + $(LIBRTLSDR_ROOT_REL)/src/tuner_fc0012.c \ + $(LIBRTLSDR_ROOT_REL)/src/tuner_fc0013.c \ + $(LIBRTLSDR_ROOT_REL)/src/tuner_fc2580.c \ + $(LIBRTLSDR_ROOT_REL)/src/tuner_r82xx.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb + +include $(BUILD_SHARED_LIBRARY) diff --git a/android/jni/tools.mk b/android/jni/tools.mk new file mode 100644 index 00000000..4127b204 --- /dev/null +++ b/android/jni/tools.mk @@ -0,0 +1,155 @@ +# Android build config for libusb examples +# Copyright © 2012-2013 RealVNC Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +LOCAL_PATH:= $(call my-dir) +LIBUSB_ROOT_REL:= ../.. +LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../.. + + +include $(CLEAR_VARS) + +LOCAL_MODULE := rtl_test + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/rtl_test.c \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb +LOCAL_SHARED_LIBRARIES += librtlsdr + +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) + +LOCAL_MODULE := rtl_sdr + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/rtl_sdr.c \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb +LOCAL_SHARED_LIBRARIES += librtlsdr + +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) + +LOCAL_MODULE := rtl_tcp + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/rtl_tcp.c \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb +LOCAL_SHARED_LIBRARIES += librtlsdr + +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) + +LOCAL_MODULE := rtl_power + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/rtl_power.c \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb +LOCAL_SHARED_LIBRARIES += librtlsdr + +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) + +LOCAL_MODULE := rtl_fm + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/rtl_fm.c \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb +LOCAL_SHARED_LIBRARIES += librtlsdr + +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) + +LOCAL_MODULE := rtl_eeprom + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/rtl_eeprom.c \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb +LOCAL_SHARED_LIBRARIES += librtlsdr + +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) + +LOCAL_MODULE := rtl_adsb + +LOCAL_SRC_FILES := \ + $(LIBRTLSDR_ROOT_REL)/src/rtl_adsb.c \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience/convenience.c \ + +LOCAL_C_INCLUDES += \ + $(LIBRTLSDR_ROOT_ABS)/include \ + $(LIBRTLSDR_ROOT_ABS)/src/convenience \ + +LOCAL_LDLIBS := -llog + +LOCAL_SHARED_LIBRARIES += libusb +LOCAL_SHARED_LIBRARIES += librtlsdr + +include $(BUILD_EXECUTABLE) diff --git a/src/rtl_fm.c b/src/rtl_fm.c index 0f7ac381..a887ebd2 100644 --- a/src/rtl_fm.c +++ b/src/rtl_fm.c @@ -271,7 +271,7 @@ int cic_9_tables[][10] = { {9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199}, }; -#ifdef _MSC_VER +#if defined(_MSC_VER ) || defined(__ANDROID__) double log2(double n) { return log(n) / log(2.0); diff --git a/src/rtl_power.c b/src/rtl_power.c index 7eb1d06e..36f8ad94 100644 --- a/src/rtl_power.c +++ b/src/rtl_power.c @@ -220,7 +220,7 @@ int cic_9_tables[][10] = { {9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199}, }; -#ifdef _MSC_VER +#if defined(_MSC_VER ) || defined(__ANDROID__) double log2(double n) { return log(n) / log(2.0);