Remove the dependency on hal and hidl from interfaces related to the memory. (#399)
author장지섭/동작제어Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Wed, 4 Apr 2018 08:29:23 +0000 (17:29 +0900)
committer최형규/동작제어Lab(SR)/Senior Engineer/삼성전자 <hk0110.choi@samsung.com>
Wed, 4 Apr 2018 08:29:23 +0000 (17:29 +0900)
This commit removes the dependency on hal and hidl from interfaces related to the memory.

- IMemory@1.0
- IAllocator@1.0

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
labs/android_nn/nn/depend/hal/CMakeLists.txt
labs/android_nn/nn/depend/hal/hidl/allocator/1.0/AllocatorAll.cpp
labs/android_nn/nn/depend/hal/hidl/memory/1.0/MemoryAll.cpp
labs/android_nn/nn/depend/hal/include/android/hidl/allocator/1.0/IAllocator.h
labs/android_nn/nn/depend/hal/include/android/hidl/memory/1.0/IMemory.h

index 9770b32..cfef4fd 100644 (file)
@@ -26,7 +26,7 @@ SET(HAL_HIDL_SRCS
   ${CMAKE_CURRENT_SOURCE_DIR}/hidl/manager/1.0/ServiceManagerAll.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/hidl/manager/1.0/ServiceNotificationAll.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/hidl/manager/1.1/ServiceManagerAll.cpp
-  ${CMAKE_CURRENT_SOURCE_DIR}/hidl/memory/1.0/MapperAll.cpp
+#  ${CMAKE_CURRENT_SOURCE_DIR}/hidl/memory/1.0/MapperAll.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/hidl/memory/1.0/MemoryAll.cpp
 )
 
index d343326..d3b0ade 100644 (file)
@@ -1,5 +1,8 @@
 #define LOG_TAG "android.hidl.allocator@1.0::Allocator"
 
+#include <android/hidl/allocator/1.0/IAllocator.h>
+
+#if 0 // REF-ANN
 #include <android/log.h>
 #include <cutils/trace.h>
 #include <hidl/HidlTransportSupport.h>
@@ -10,6 +13,7 @@
 #include <android/hidl/allocator/1.0/BsAllocator.h>
 #include <android/hidl/base/1.0/BpHwBase.h>
 #include <hidl/ServiceManagement.h>
+#endif // REF-ANN
 
 namespace android {
 namespace hidl {
@@ -26,6 +30,7 @@ std::string toString(const ::android::sp<IAllocator>& o) {
 
 const char* IAllocator::descriptor("android.hidl.allocator@1.0::IAllocator");
 
+#if 0 // REF-ANN
 __attribute__((constructor))static void static_constructor() {
     ::android::hardware::details::gBnConstructorMap.set(IAllocator::descriptor,
             [](void *iIntf) -> ::android::sp<::android::hardware::IBinder> {
@@ -800,9 +805,13 @@ BsAllocator::BsAllocator(const ::android::sp<IAllocator> impl) : ::android::hard
     }
     return iface;
 }
+#endif // REF-ANN
 
 // static
 ::android::sp<IAllocator> IAllocator::getService(const std::string &serviceName, const bool getStub) {
+    // TODO-NNRT re-implement this. Should return an Allocator appropriate for serviceName.
+    return nullptr;
+#if 0 // REF-ANN
     using ::android::hardware::defaultServiceManager;
     using ::android::hardware::details::waitForHwService;
     using ::android::hardware::getPassthroughServiceManager;
@@ -900,8 +909,10 @@ BsAllocator::BsAllocator(const ::android::sp<IAllocator> impl) : ::android::hard
         }
     }
     return iface;
+#endif // REF-ANN
 }
 
+#if 0 // REF-ANN
 ::android::status_t IAllocator::registerAsService(const std::string &serviceName) {
     ::android::hardware::details::onRegistration("android.hidl.allocator@1.0", "IAllocator", serviceName);
 
@@ -933,6 +944,7 @@ static_assert(sizeof(::android::hardware::hidl_handle) == 16, "wrong size");
 static_assert(sizeof(::android::hardware::hidl_memory) == 40, "wrong size");
 static_assert(sizeof(::android::hardware::hidl_string) == 16, "wrong size");
 static_assert(sizeof(::android::hardware::hidl_vec<char>) == 16, "wrong size");
+#endif // REF-ANN
 
 }  // namespace V1_0
 }  // namespace allocator
index 0358a11..e2fb365 100644 (file)
@@ -1,5 +1,7 @@
 #define LOG_TAG "android.hidl.memory@1.0::Memory"
 
+#include <android/hidl/memory/1.0/IMemory.h>
+#if 0 // REF-ANN
 #include <android/log.h>
 #include <cutils/trace.h>
 #include <hidl/HidlTransportSupport.h>
@@ -10,6 +12,7 @@
 #include <android/hidl/memory/1.0/BsMemory.h>
 #include <android/hidl/base/1.0/BpHwBase.h>
 #include <hidl/ServiceManagement.h>
+#endif // REF-ANN
 
 namespace android {
 namespace hidl {
@@ -26,6 +29,7 @@ std::string toString(const ::android::sp<IMemory>& o) {
 
 const char* IMemory::descriptor("android.hidl.memory@1.0::IMemory");
 
+#if 0 // REF-ANN
 __attribute__((constructor))static void static_constructor() {
     ::android::hardware::details::gBnConstructorMap.set(IMemory::descriptor,
             [](void *iIntf) -> ::android::sp<::android::hardware::IBinder> {
@@ -1359,6 +1363,7 @@ static_assert(sizeof(::android::hardware::hidl_handle) == 16, "wrong size");
 static_assert(sizeof(::android::hardware::hidl_memory) == 40, "wrong size");
 static_assert(sizeof(::android::hardware::hidl_string) == 16, "wrong size");
 static_assert(sizeof(::android::hardware::hidl_vec<char>) == 16, "wrong size");
+#endif // REF-ANN
 
 }  // namespace V1_0
 }  // namespace memory
index 89b3c83..104ee36 100644 (file)
@@ -1,28 +1,38 @@
 #ifndef HIDL_GENERATED_ANDROID_HIDL_ALLOCATOR_V1_0_IALLOCATOR_H
 #define HIDL_GENERATED_ANDROID_HIDL_ALLOCATOR_V1_0_IALLOCATOR_H
 
+#include <hidl/Status.h>
+#include <utils/RefBase.h>
+#include <hidl/HidlSupport.h>
+#if 0 // REF-ANN
 #include <android/hidl/base/1.0/IBase.h>
 
 #include <android/hidl/manager/1.0/IServiceNotification.h>
 
-#include <hidl/HidlSupport.h>
 #include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
 #include <utils/NativeHandle.h>
 #include <utils/misc.h>
+#endif // REF-ANN
 
 namespace android {
 namespace hidl {
 namespace allocator {
 namespace V1_0 {
 
-struct IAllocator : public ::android::hidl::base::V1_0::IBase {
-    virtual bool isRemote() const override { return false; }
+struct IAllocator : virtual public ::android::RefBase {
+    static const char* descriptor;
 
+    virtual bool isRemote() const { return false; }
 
     using allocate_cb = std::function<void(bool success, const ::android::hardware::hidl_memory& mem)>;
     virtual ::android::hardware::Return<void> allocate(uint64_t size, allocate_cb _hidl_cb) = 0;
 
+    static ::android::sp<IAllocator> getService(const std::string &serviceName="default", bool getStub=false);
+    static ::android::sp<IAllocator> getService(const ::android::hardware::hidl_string& serviceName, bool getStub=false)  { std::string str(serviceName.c_str());      return getService(str, getStub); }
+};
+
+#if 0 // REF-ANN
+struct IAllocator : public ::android::hidl::base::V1_0::IBase {
     using batchAllocate_cb = std::function<void(bool success, const ::android::hardware::hidl_vec<::android::hardware::hidl_memory>& batch)>;
     virtual ::android::hardware::Return<void> batchAllocate(uint64_t size, uint64_t count, batchAllocate_cb _hidl_cb) = 0;
 
@@ -53,21 +63,18 @@ struct IAllocator : public ::android::hidl::base::V1_0::IBase {
     static ::android::hardware::Return<::android::sp<IAllocator>> castFrom(const ::android::sp<IAllocator>& parent, bool emitError = false);
     static ::android::hardware::Return<::android::sp<IAllocator>> castFrom(const ::android::sp<::android::hidl::base::V1_0::IBase>& parent, bool emitError = false);
 
-    static const char* descriptor;
-
     static ::android::sp<IAllocator> tryGetService(const std::string &serviceName="default", bool getStub=false);
     static ::android::sp<IAllocator> tryGetService(const char serviceName[], bool getStub=false)  { std::string str(serviceName ? serviceName : "");      return tryGetService(str, getStub); }
     static ::android::sp<IAllocator> tryGetService(const ::android::hardware::hidl_string& serviceName, bool getStub=false)  { std::string str(serviceName.c_str());      return tryGetService(str, getStub); }
     static ::android::sp<IAllocator> tryGetService(bool getStub) { return tryGetService("default", getStub); }
-    static ::android::sp<IAllocator> getService(const std::string &serviceName="default", bool getStub=false);
     static ::android::sp<IAllocator> getService(const char serviceName[], bool getStub=false)  { std::string str(serviceName ? serviceName : "");      return getService(str, getStub); }
-    static ::android::sp<IAllocator> getService(const ::android::hardware::hidl_string& serviceName, bool getStub=false)  { std::string str(serviceName.c_str());      return getService(str, getStub); }
     static ::android::sp<IAllocator> getService(bool getStub) { return getService("default", getStub); }
     __attribute__ ((warn_unused_result))::android::status_t registerAsService(const std::string &serviceName="default");
     static bool registerForNotifications(
             const std::string &serviceName,
             const ::android::sp<::android::hidl::manager::V1_0::IServiceNotification> &notification);
 };
+#endif // REF-ANN
 
 std::string toString(const ::android::sp<IAllocator>&);
 
index d0a688b..96dd25d 100644 (file)
@@ -1,37 +1,42 @@
 #ifndef HIDL_GENERATED_ANDROID_HIDL_MEMORY_V1_0_IMEMORY_H
 #define HIDL_GENERATED_ANDROID_HIDL_MEMORY_V1_0_IMEMORY_H
 
+
+#include <hidl/Status.h>
+#include <utils/RefBase.h>
+#if 0 // REF-ANN
 #include <android/hidl/base/1.0/IBase.h>
 
 #include <android/hidl/manager/1.0/IServiceNotification.h>
 
 #include <hidl/HidlSupport.h>
 #include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
 #include <utils/NativeHandle.h>
 #include <utils/misc.h>
+#endif // REF-ANN
 
 namespace android {
 namespace hidl {
 namespace memory {
 namespace V1_0 {
 
-struct IMemory : public ::android::hidl::base::V1_0::IBase {
-    virtual bool isRemote() const override { return false; }
-
+struct IMemory : virtual public ::android::RefBase {
+    static const char* descriptor;
 
+    virtual bool isRemote() const { return false; }
+    virtual ::android::hardware::Return<void*> getPointer() = 0;
     virtual ::android::hardware::Return<void> update() = 0;
+    virtual ::android::hardware::Return<void> commit() = 0;
+};
 
+#if 0 // REF-ANN
+struct IMemory : public ::android::hidl::base::V1_0::IBase {
     virtual ::android::hardware::Return<void> updateRange(uint64_t start, uint64_t length) = 0;
 
     virtual ::android::hardware::Return<void> read() = 0;
 
     virtual ::android::hardware::Return<void> readRange(uint64_t start, uint64_t length) = 0;
 
-    virtual ::android::hardware::Return<void> commit() = 0;
-
-    virtual ::android::hardware::Return<void*> getPointer() = 0;
-
     virtual ::android::hardware::Return<uint64_t> getSize() = 0;
 
     using interfaceChain_cb = std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& descriptors)>;
@@ -61,8 +66,6 @@ struct IMemory : public ::android::hidl::base::V1_0::IBase {
     static ::android::hardware::Return<::android::sp<IMemory>> castFrom(const ::android::sp<IMemory>& parent, bool emitError = false);
     static ::android::hardware::Return<::android::sp<IMemory>> castFrom(const ::android::sp<::android::hidl::base::V1_0::IBase>& parent, bool emitError = false);
 
-    static const char* descriptor;
-
     static ::android::sp<IMemory> tryGetService(const std::string &serviceName="default", bool getStub=false);
     static ::android::sp<IMemory> tryGetService(const char serviceName[], bool getStub=false)  { std::string str(serviceName ? serviceName : "");      return tryGetService(str, getStub); }
     static ::android::sp<IMemory> tryGetService(const ::android::hardware::hidl_string& serviceName, bool getStub=false)  { std::string str(serviceName.c_str());      return tryGetService(str, getStub); }
@@ -76,6 +79,7 @@ struct IMemory : public ::android::hidl::base::V1_0::IBase {
             const std::string &serviceName,
             const ::android::sp<::android::hidl::manager::V1_0::IServiceNotification> &notification);
 };
+#endif // REF-ANN
 
 std::string toString(const ::android::sp<IMemory>&);