1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef USB_DDK_SERVICE_H 17 #define USB_DDK_SERVICE_H 18 19 #include "v1_0/iusb_ddk.h" 20 21 namespace OHOS { 22 namespace HDI { 23 namespace Usb { 24 namespace Ddk { 25 namespace V1_0 { 26 class UsbDdkService : public IUsbDdk { 27 public: 28 UsbDdkService() = default; 29 virtual ~UsbDdkService() = default; 30 31 int32_t Init() override; 32 33 int32_t Release() override; 34 35 int32_t GetDeviceDescriptor(uint64_t deviceId, UsbDeviceDescriptor &desc) override; 36 37 int32_t GetConfigDescriptor(uint64_t deviceId, uint8_t configIndex, std::vector<uint8_t> &configDesc) override; 38 39 int32_t ClaimInterface(uint64_t deviceId, uint8_t interfaceIndex, uint64_t &interfaceHandle) override; 40 41 int32_t ReleaseInterface(uint64_t interfaceHandle) override; 42 43 int32_t SelectInterfaceSetting(uint64_t interfaceHandle, uint8_t settingIndex) override; 44 45 int32_t GetCurrentInterfaceSetting(uint64_t interfaceHandle, uint8_t &settingIndex) override; 46 47 int32_t SendControlReadRequest(uint64_t interfaceHandle, const UsbControlRequestSetup &setup, uint32_t timeout, 48 std::vector<uint8_t> &data) override; 49 50 int32_t SendControlWriteRequest(uint64_t interfaceHandle, const UsbControlRequestSetup &setup, uint32_t timeout, 51 const std::vector<uint8_t> &data) override; 52 53 int32_t SendPipeRequest(const UsbRequestPipe &pipe, uint32_t size, uint32_t offset, uint32_t length, 54 uint32_t &transferedLength) override; 55 56 int32_t SendPipeRequestWithAshmem(const UsbRequestPipe &pipe, const UsbAshmem &ashmem, 57 uint32_t &transferredLength) override; 58 59 int32_t GetDeviceMemMapFd(uint64_t deviceId, int &fd) override; 60 }; 61 } // namespace V1_0 62 } // namespace Ddk 63 } // namespace Usb 64 } // namespace HDI 65 } // namespace OHOS 66 #endif // USB_DDK_SERVICE_H