1 /* 2 * Copyright (c) 2021 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 USBFN_REQUEST_H 17 #define USBFN_REQUEST_H 18 19 #include "usb_object.h" 20 21 typedef enum { 22 USB_REQUEST_TYPE_INVALID, 23 USB_REQUEST_TYPE_PIPE_WRITE, 24 USB_REQUEST_TYPE_PIPE_READ, 25 } UsbFnRequestType; 26 27 struct UsbFnRequest { 28 const struct UsbObject *obj; 29 30 struct DListHead list; 31 32 void *buf; 33 uint32_t length; 34 35 UsbFnRequestType type; 36 UsbRequestStatus status; 37 38 uint32_t actual; 39 void (*complete)(uint8_t pipe, struct UsbFnRequest *req); 40 void *context; 41 }; 42 43 typedef void *UsbFnInterfaceHandle; 44 45 struct UsbFnRequest *UsbFnAllocCtrlRequest(UsbFnInterfaceHandle handle, uint32_t len); 46 struct UsbFnRequest *UsbFnAllocRequest(UsbFnInterfaceHandle handle, uint8_t pipe, uint32_t len); 47 int UsbFnFreeRequest(struct UsbFnRequest *req); 48 int UsbFnGetRequestStatus(struct UsbFnRequest *req, UsbRequestStatus *status); 49 int UsbFnSubmitRequestAsync(struct UsbFnRequest *req); 50 int UsbFnCancelRequest(struct UsbFnRequest *req); 51 int UsbFnSubmitRequestSync(struct UsbFnRequest *req, uint32_t timeout); 52 53 #endif /* USBFN_REQUEST_H */ 54