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 USB_DDK_DEVICE_H 17 #define USB_DDK_DEVICE_H 18 19 #include "usb_ddk.h" 20 #include "usb_session.h" 21 22 #define USB_MAXENDPOINTS 32 23 #define USB_MAXALTSETTING 128 24 25 struct UsbDeviceConfigDescriptor { 26 struct UsbConfigDescriptor *desc; 27 size_t actualLen; 28 }; 29 30 struct UsbDevice { 31 struct HdfSListNode list; 32 OsalAtomic refcnt; 33 struct UsbSession *session; 34 struct UsbDevice *parentDev; 35 struct UsbDeviceHandle *devHandle; 36 uint8_t busNum; 37 uint8_t portNum; 38 uint8_t devAddr; 39 enum UsbDeviceSpeed speed; 40 struct UsbDeviceDescriptor deviceDescriptor; 41 void *descriptors; 42 size_t descriptorsLength; 43 uint8_t activeConfig; 44 struct UsbDeviceConfigDescriptor *configDescriptors; 45 struct OsalMutex requestLock; 46 struct HdfSList requestList; 47 void *privateObject; 48 void *privateData; 49 }; 50 51 struct UsbDeviceHandle { 52 struct OsalMutex lock; 53 uint64_t claimedInterfaces; 54 struct UsbDevice *dev; 55 struct UsbSession *session; 56 uint32_t caps; 57 int32_t fd; 58 int32_t mmapFd; 59 }; 60 61 #endif /* USB_DDK_DEVICE_H */ 62