1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#ifndef USB_DDK_DEVICE_H 17094332d3Sopenharmony_ci#define USB_DDK_DEVICE_H 18094332d3Sopenharmony_ci 19094332d3Sopenharmony_ci#include "usb_ddk.h" 20094332d3Sopenharmony_ci#include "usb_session.h" 21094332d3Sopenharmony_ci 22094332d3Sopenharmony_ci#define USB_MAXENDPOINTS 32 23094332d3Sopenharmony_ci#define USB_MAXALTSETTING 128 24094332d3Sopenharmony_ci 25094332d3Sopenharmony_cistruct UsbDeviceConfigDescriptor { 26094332d3Sopenharmony_ci struct UsbConfigDescriptor *desc; 27094332d3Sopenharmony_ci size_t actualLen; 28094332d3Sopenharmony_ci}; 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_cistruct UsbDevice { 31094332d3Sopenharmony_ci struct HdfSListNode list; 32094332d3Sopenharmony_ci OsalAtomic refcnt; 33094332d3Sopenharmony_ci struct UsbSession *session; 34094332d3Sopenharmony_ci struct UsbDevice *parentDev; 35094332d3Sopenharmony_ci struct UsbDeviceHandle *devHandle; 36094332d3Sopenharmony_ci uint8_t busNum; 37094332d3Sopenharmony_ci uint8_t portNum; 38094332d3Sopenharmony_ci uint8_t devAddr; 39094332d3Sopenharmony_ci enum UsbDeviceSpeed speed; 40094332d3Sopenharmony_ci struct UsbDeviceDescriptor deviceDescriptor; 41094332d3Sopenharmony_ci void *descriptors; 42094332d3Sopenharmony_ci size_t descriptorsLength; 43094332d3Sopenharmony_ci uint8_t activeConfig; 44094332d3Sopenharmony_ci struct UsbDeviceConfigDescriptor *configDescriptors; 45094332d3Sopenharmony_ci struct OsalMutex requestLock; 46094332d3Sopenharmony_ci struct HdfSList requestList; 47094332d3Sopenharmony_ci void *privateObject; 48094332d3Sopenharmony_ci void *privateData; 49094332d3Sopenharmony_ci}; 50094332d3Sopenharmony_ci 51094332d3Sopenharmony_cistruct UsbDeviceHandle { 52094332d3Sopenharmony_ci struct OsalMutex lock; 53094332d3Sopenharmony_ci uint64_t claimedInterfaces; 54094332d3Sopenharmony_ci struct UsbDevice *dev; 55094332d3Sopenharmony_ci struct UsbSession *session; 56094332d3Sopenharmony_ci uint32_t caps; 57094332d3Sopenharmony_ci int32_t fd; 58094332d3Sopenharmony_ci int32_t mmapFd; 59094332d3Sopenharmony_ci int32_t ashmemFd; 60094332d3Sopenharmony_ci bool isAshmem; 61094332d3Sopenharmony_ci uint64_t detachedInterfaces; 62094332d3Sopenharmony_ci uint64_t attachedInterfaces; 63094332d3Sopenharmony_ci}; 64094332d3Sopenharmony_ci 65094332d3Sopenharmony_ci#endif /* USB_DDK_DEVICE_H */ 66