1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_PACKAGES_MODULES_NEURALNETWORKS_DRIVER_SAMPLE_AIDL_SAMPLE_DRIVER_AIDL_UTILS_H 18 #define ANDROID_PACKAGES_MODULES_NEURALNETWORKS_DRIVER_SAMPLE_AIDL_SAMPLE_DRIVER_AIDL_UTILS_H 19 20 #include <android/binder_auto_utils.h> 21 22 #include <memory> 23 #include <string> 24 #include <utility> 25 #include <vector> 26 27 #include "SampleDriverAidl.h" 28 29 namespace android { 30 namespace nn { 31 namespace sample_driver_aidl { 32 33 // Starts and runs the driver service. Typically called from main(). 34 // This will return only once the service shuts down. 35 int run(const std::shared_ptr<aidl_hal::BnDevice>& device, const std::string& name); 36 37 void notify(const std::shared_ptr<aidl_hal::IPreparedModelCallback>& callback, 38 const aidl_hal::ErrorStatus& status, 39 const std::shared_ptr<aidl_hal::IPreparedModel>& preparedModel); 40 41 ndk::ScopedAStatus prepareModelBase( 42 aidl_hal::Model&& model, const SampleDriver* driver, 43 aidl_hal::ExecutionPreference preference, aidl_hal::Priority priority, int64_t halDeadline, 44 const std::shared_ptr<aidl_hal::IPreparedModelCallback>& callback, 45 bool isFullModelSupported = true); 46 47 ndk::ScopedAStatus toAStatus(aidl_hal::ErrorStatus errorStatus); 48 ndk::ScopedAStatus toAStatus(aidl_hal::ErrorStatus errorStatus, const std::string& errorMessage); 49 50 } // namespace sample_driver_aidl 51 } // namespace nn 52 } // namespace android 53 54 #endif // ANDROID_PACKAGES_MODULES_NEURALNETWORKS_DRIVER_SAMPLE_AIDL_SAMPLE_DRIVER_AIDL_UTILS_H 55