1 /* 2 * Copyright (c) 2021-2022 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_DEVICE_PIPE_H 17 #define USB_DEVICE_PIPE_H 18 19 #include "iusb_srv.h" 20 #include "usb_config.h" 21 #include "v1_2/usb_types.h" 22 23 namespace OHOS { 24 namespace USB { 25 class USBDevicePipe { 26 public: 27 USBDevicePipe(); ~USBDevicePipe()28 ~USBDevicePipe() {} 29 USBDevicePipe(uint8_t busNum, uint8_t devAddr); 30 int32_t ClaimInterface(const UsbInterface &interface, bool force); 31 int32_t ReleaseInterface(const UsbInterface &interface); 32 int32_t BulkTransfer(const USBEndpoint &endpoint, std::vector<uint8_t> &bufferData, int32_t timeOut); 33 34 int32_t UsbSubmitTransfer(HDI::Usb::V1_2::USBTransferInfo &info, const TransferCallback &cb, 35 sptr<Ashmem> &ashmem); 36 int32_t UsbCancelTransfer(int32_t &endpoint); 37 38 int32_t ControlTransfer(const HDI::Usb::V1_0::UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData); 39 int32_t UsbControlTransfer( 40 const HDI::Usb::V1_2::UsbCtrlTransferParams &ctrlParams, std::vector<uint8_t> &bufferData); 41 int32_t SetConfiguration(const USBConfig &config); 42 int32_t SetInterface(const UsbInterface &interface); 43 int32_t Close(); 44 45 void SetBusNum(uint8_t busNum); 46 void SetDevAddr(uint8_t devAddr); 47 uint8_t GetBusNum() const; 48 uint8_t GetDevAddr() const; 49 uint8_t GetBusNum(); 50 uint8_t GetDevAddr(); 51 private: 52 uint8_t busNum_ = UINT8_MAX; 53 uint8_t devAddr_ = UINT8_MAX; 54 }; 55 } // namespace USB 56 } // namespace OHOS 57 58 #endif // USB_DEVICE_PIPE_H 59