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/* * 17 * @addtogroup HdiUsbDdk 18 * @{ 19 * 20 * @brief Provides USB DDK types and declares the macros, enumerated variables, and\n 21 * data structures required by the USB DDK APIs. 22 * 23 * @since 4.0 24 */ 25 26/** 27 * @file UsbDdkTypes.idl 28 * 29 * @brief Provides the enumerated variables, structures, and macros used in USB DDK APIs. 30 * 31 * @since 4.0 32 * @version 1.0 33 */ 34 35package ohos.hdi.usb.ddk.v1_0; 36 37/* * 38 * @brief Setup data for control transfer. It corresponds to <b>Setup Data</b> in the USB protocol. 39 */ 40struct UsbControlRequestSetup { 41 /** Request type, corresponding to bmRequestType in the USB protocol. */ 42 unsigned char requestType; 43 /** Request command, corresponding to bRequest in the USB protocol. */ 44 unsigned char requestCmd; 45 /** Value corresponding to wValue in the USB protocol. Its meaning varies according to the request. */ 46 unsigned short value; 47 /** Index corresponding to wIndex in the USB protocol. It is usually used to transfer the index or offset.\n 48 * Its meaning varies according to the request. 49 */ 50 unsigned short index; 51 /** Data length, corresponding to wLength in the USB protocol. If data is transferred,\n 52 * this field indicates the number of transferred bytes. 53 */ 54 unsigned short length; 55}; 56 57/* * 58 * @brief Standard device descriptor, corresponding to <b>Standard Device Descriptor</b> in the USB protocol. 59 */ 60struct UsbDeviceDescriptor { 61 /** Size of the descriptor, in bytes. */ 62 unsigned char bLength; 63 /** Descriptor type. */ 64 unsigned char bDescriptorType; 65 /** USB protocol release number. */ 66 unsigned short bcdUSB; 67 /** Device class code allocated by the USB-IF. */ 68 unsigned char bDeviceClass; 69 /** Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass. */ 70 unsigned char bDeviceSubClass; 71 /** Protocol code allocated by USB-IF. The value is limited by that of bDeviceClass and bDeviceSubClass. */ 72 unsigned char bDeviceProtocol; 73 /** Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid. */ 74 unsigned char bMaxPacketSize0; 75 /** Vendor ID allocated by USB-IF. */ 76 unsigned short idVendor; 77 /** Product ID allocated by the vendor. */ 78 unsigned short idProduct; 79 /** Device release number. */ 80 unsigned short bcdDevice; 81 /** Index of the string descriptor that describes the vendor. */ 82 unsigned char iManufacturer; 83 /** Index of the string descriptor that describes the product. */ 84 unsigned char iProduct; 85 /** Index of the string descriptor that describes the device SN. */ 86 unsigned char iSerialNumber; 87 /** Configuration quantity. */ 88 unsigned char bNumConfigurations; 89}; 90 91 92/** 93 * @brief Request pipe. 94 */ 95struct UsbRequestPipe { 96 /** Interface operation handle. */ 97 unsigned long interfaceHandle; 98 /** Timeout duration, in milliseconds. */ 99 unsigned int timeout; 100 /** Endpoint address. */ 101 unsigned char endpoint; 102}; 103 104/** 105 * @brief Usb Ashmem. 106 * 107 * @since 5.0 108 * @version 1.0 109 */ 110struct UsbAshmem { 111 /** File descriptor of the shared memory. */ 112 FileDescriptor ashmemFd; 113 /** Buffer address. */ 114 unsigned char[] address; 115 /** Buffer size. */ 116 unsigned int size; 117 /** Offset of the used buffer. The default value is 0, which indicates that there is no offset\n 118 * and the buffer starts from the specified address. 119 */ 120 unsigned int offset; 121 /** Length of the used buffer. By default, the value is equal to the size, which indicates that\n 122 * the entire buffer is used. 123 */ 124 unsigned int bufferLength; 125 /** Length of the transferred data. */ 126 unsigned int transferredLength; 127}; 128