1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef HDF_USB_PNP_MANAGE_H 10 #define HDF_USB_PNP_MANAGE_H 11 12 #include "hdf_base.h" 13 14 #define USB_PNP_NOTIFY_TEST_MODE false 15 #define USB_PNP_INFO_MAX_INTERFACES 32 16 17 enum UsbPnpNotifyServiceCmd { 18 USB_PNP_NOTIFY_ADD_INTERFACE, 19 USB_PNP_NOTIFY_REMOVE_INTERFACE, 20 USB_PNP_NOTIFY_REPORT_INTERFACE, 21 USB_PNP_NOTIFY_ADD_DEVICE, 22 USB_PNP_NOTIFY_REMOVE_DEVICE, 23 #if USB_PNP_NOTIFY_TEST_MODE == true 24 USB_PNP_NOTIFY_ADD_TEST, 25 USB_PNP_NOTIFY_REMOVE_TEST, 26 #endif 27 USB_PNP_DRIVER_REGISTER_DEVICE, 28 USB_PNP_DRIVER_UNREGISTER_DEVICE, 29 USB_PNP_DRIVER_GETDEVICES = 20, 30 USB_PNP_DRIVER_GADGET_ADD = 30, 31 USB_PNP_DRIVER_GADGET_REMOVE, 32 }; 33 34 enum UsbPnpNotifyRemoveType { 35 USB_PNP_NOTIFY_REMOVE_BUS_DEV_NUM, 36 USB_PNP_NOTIFY_REMOVE_INTERFACE_NUM, 37 }; 38 39 enum { 40 USB_PNP_NOTIFY_MATCH_VENDOR = 0x0001, 41 USB_PNP_NOTIFY_MATCH_PRODUCT = 0x0002, 42 USB_PNP_NOTIFY_MATCH_DEV_LOW = 0x0004, 43 USB_PNP_NOTIFY_MATCH_DEV_HIGH = 0x0008, 44 USB_PNP_NOTIFY_MATCH_DEV_CLASS = 0x0010, 45 USB_PNP_NOTIFY_MATCH_DEV_SUBCLASS = 0x0020, 46 USB_PNP_NOTIFY_MATCH_DEV_PROTOCOL = 0x0040, 47 USB_PNP_NOTIFY_MATCH_INT_CLASS = 0x0080, 48 USB_PNP_NOTIFY_MATCH_INT_SUBCLASS = 0x0100, 49 USB_PNP_NOTIFY_MATCH_INT_PROTOCOL = 0x0200, 50 USB_PNP_NOTIFY_MATCH_INT_NUMBER = 0x0400, 51 }; 52 53 struct UsbPnpNotifyServiceInfo { 54 uint32_t length; 55 56 int32_t devNum; 57 int32_t busNum; 58 59 int32_t interfaceLength; 60 uint8_t interfaceNumber[USB_PNP_INFO_MAX_INTERFACES]; 61 } __attribute__ ((packed)); 62 63 struct UsbPnpNotifyInterfaceInfo { 64 uint8_t interfaceClass; 65 uint8_t interfaceSubClass; 66 uint8_t interfaceProtocol; 67 68 uint8_t interfaceNumber; 69 }; 70 71 struct UsbPnpNotifyDeviceInfo { 72 uint16_t vendorId; 73 uint16_t productId; 74 75 uint16_t bcdDeviceLow; 76 uint16_t bcdDeviceHigh; 77 78 uint8_t deviceClass; 79 uint8_t deviceSubClass; 80 uint8_t deviceProtocol; 81 }; 82 83 struct UsbPnpNotifyMatchInfoTable { 84 uint64_t usbDevAddr; 85 int32_t devNum; 86 int32_t busNum; 87 88 struct UsbPnpNotifyDeviceInfo deviceInfo; 89 90 uint8_t removeType; 91 uint8_t numInfos; 92 93 struct UsbPnpNotifyInterfaceInfo interfaceInfo[USB_PNP_INFO_MAX_INTERFACES]; 94 }; 95 96 struct UsbPnpAddRemoveInfo { 97 int32_t devNum; 98 int32_t busNum; 99 uint8_t interfaceNumber; 100 uint8_t interfaceClass; 101 uint8_t interfaceSubClass; 102 uint8_t interfaceProtocol; 103 }; 104 105 #endif /* HDF_USB_PNP_MANAGE_H */ 106