diff --git a/usb/bundle.json b/usb/bundle.json
index 8fdca89e462c86820fdfaabe810191152b625471..f24c4ad401319df0858801c5a1fd96fc75285204 100644
--- a/usb/bundle.json
+++ b/usb/bundle.json
@@ -32,6 +32,7 @@
"sub_component": [
"//drivers/interface/usb/v1_0:usb_idl_target",
"//drivers/interface/usb/v1_1:usb_idl_target",
+ "//drivers/interface/usb/v1_2:usb_idl_target",
"//drivers/interface/usb/gadget/mtp/v1_0:usbfn_mtp_idl_target",
"//drivers/interface/usb/ddk/v1_0:usb_ddk_idl_target"
],
@@ -120,6 +121,27 @@
"header_files": [],
"header_base": "//drivers/interface/usb"
}
+ },
+ {
+ "name": "//drivers/interface/usb/v1_2:libusb_proxy_1.2",
+ "header": {
+ "header_files": [],
+ "header_base": "//drivers/interface/usb"
+ }
+ },
+ {
+ "name": "//drivers/interface/usb/v1_2:libusb_stub_1.2",
+ "header": {
+ "header_files": [],
+ "header_base": "//drivers/interface/usb"
+ }
+ },
+ {
+ "name": "//drivers/interface/usb/v1_2:usb_idl_headers_1.2",
+ "header": {
+ "header_files": [],
+ "header_base": "//drivers/interface/usb"
+ }
}
]
}
diff --git a/usb/v1_2/BUILD.gn b/usb/v1_2/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..05b12c1a6f125c0af9a667eb3ad5667ebc35cd15
--- /dev/null
+++ b/usb/v1_2/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/config/components/hdi/hdi.gni")
+if (defined(ohos_lite)) {
+ group("libusb_proxy_1.2") {
+ deps = []
+ public_configs = []
+ }
+} else {
+ hdi("usb") {
+ module_name = "usbd"
+ imports = [
+ "ohos.hdi.usb.v1_0:usb",
+ "ohos.hdi.usb.v1_1:usb"
+ ]
+
+ sources = [
+ "IUsbDeviceInterface.idl",
+ "IUsbHostInterface.idl",
+ "IUsbPortInterface.idl",
+ "UsbPortTypes.idl"
+ ]
+
+ language = "cpp"
+ subsystem_name = "hdf"
+ part_name = "drivers_interface_usb"
+ }
+}
diff --git a/usb/v1_2/IUsbDeviceInterface.idl b/usb/v1_2/IUsbDeviceInterface.idl
new file mode 100644
index 0000000000000000000000000000000000000000..35f1619bf7adb9d4b77fc7ee9c10aba7a54ccab1
--- /dev/null
+++ b/usb/v1_2/IUsbDeviceInterface.idl
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ /* *
+ * @addtogroup HdiUsb
+ * @{
+ *
+ * @brief Provides unified APIs for usb services to access usb drivers.
+ *
+ * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to
+ * access different types of usb devices based on the usb IDs, thereby obtaining usb information,
+ * subscribing to or unsubscribing from usb data, enabling or disabling a usb,
+ * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range.
+ *
+ * @since 5.1
+ */
+/* *
+ * @file IUsbDeviceInterface.idl
+ *
+ * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or
+ * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode,
+ * and setting usb options such as the accuracy and measurement range.
+ *
+ * @since 5.1
+ * @version 2.0
+ */
+
+package ohos.hdi.usb.v1_2;
+
+import ohos.hdi.usb.v1_0.UsbTypes;
+import ohos.hdi.usb.v1_0.IUsbdSubscriber;
+
+interface IUsbDeviceInterface {
+
+ /* *
+ * @brief Obtains the list of functions (represented by bit field) supported by the current device.
+ *
+ * @param funcs Indicates the list of functions supported by the current device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetCurrentFunctions([out] int funcs);
+
+ /* *
+ * @brief Sets the list of functions (represented by bit field) supported by the current device.
+ *
+ * @param funcs Indicates the list of functions supported by the current device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ SetCurrentFunctions([in] int funcs);
+
+ /* *
+ * @brief Binds a subscriber.
+ *
+ * @param subscriber Indicates the subscriber.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ BindUsbdSubscriber([in] IUsbdSubscriber subscriber);
+
+ /* *
+ * @brief Unbinds a subscriber.
+ *
+ * @param subscriber Indicates the subscriber.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ UnbindUsbdSubscriber([in] IUsbdSubscriber subscriber);
+
+ /* *
+ * @brief Get Accessory Strings.
+ *
+ * @param accessoryInfo Indicates the accessory information.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ GetAccessoryStrings([out] String[] accessoryInfo);
+
+ /* *
+ * @brief open the accessory.
+ *
+ * @param fd accessory file descriptor
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ OpenAccessory([out] FileDescriptor fd);
+
+ /* *
+ * @brief close the accessory.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ CloseAccessory();
+}
\ No newline at end of file
diff --git a/usb/v1_2/IUsbHostInterface.idl b/usb/v1_2/IUsbHostInterface.idl
new file mode 100644
index 0000000000000000000000000000000000000000..7d660d23b842ab377639164f8aa8f5024f13ad6c
--- /dev/null
+++ b/usb/v1_2/IUsbHostInterface.idl
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* *
+ * @addtogroup HdiUsb
+ * @{
+ *
+ * @brief Provides unified APIs for usb services to access usb drivers.
+ *
+ * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to
+ * access different types of usb devices based on the usb IDs, thereby obtaining usb information,
+ * subscribing to or unsubscribing from usb data, enabling or disabling a usb,
+ * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range.
+ *
+ * @since 5.1
+ */
+
+/* *
+ * @file IUsbHostInterface.idl
+ *
+ * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or
+ * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode,
+ * and setting usb options such as the accuracy and measurement range.
+ *
+ * @since 5.1
+ * @version 2.0
+ */
+
+package ohos.hdi.usb.v1_2;
+
+import ohos.hdi.usb.v1_0.IUsbdSubscriber;
+import ohos.hdi.usb.v1_0.UsbTypes;
+import ohos.hdi.usb.v1_1.UsbTypes;
+
+/* *
+ * @brief Defines the functions for performing basic operations on usb.
+ *
+ * The operations include obtaining usb information, subscribing to or unsubscribing from usb data,
+ * enabling or disabling a usb, setting the usb data reporting mode, and setting usb options such as
+ * the accuracy and measurement range.
+ */
+interface IUsbHostInterface {
+
+ /* *
+ * @brief Opens a USB device to set up a connection.
+ *
+ * @param dev Indicates the USB device address.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ OpenDevice([in] struct UsbDev dev);
+
+ /* *
+ * @brief Closes a USB device to release all system resources related to the device.
+ *
+ * @param dev Indicates the USB device address.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ CloseDevice([in] struct UsbDev dev);
+
+ /* *
+ * @brief Obtains the string descriptor of a USB device based on the specified string ID.
+ *
+ * @param dev Indicates the USB device address.
+ * @param descId Indicates string descriptor ID.
+ * @param descriptor Indicates the configuration descriptor of the USB device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetStringDescriptor([in] struct UsbDev dev, [in] unsigned char descId, [out] unsigned char[] descriptor);
+
+ /* *
+ * @brief Obtains the raw descriptor.
+ *
+ * @param dev Indicates the USB device address.
+ * @param descriptor Indicates the raw descriptor of the USB device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetRawDescriptor([in] struct UsbDev dev, [out] unsigned char[] descriptor);
+
+ /* *
+ * @brief Sets the configuration information of a USB device.
+ *
+ * @param dev Indicates the USB device address.
+ * @param configIndex Indicates the configuration information of the USB device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ SetConfig([in] struct UsbDev dev, [in] unsigned char configIndex);
+
+ /* *
+ * @brief Obtains the configuration information of a USB device.
+ *
+ * @param dev Indicates the USB device address.
+ * @param configIndex Indicates the configuration information of the USB device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetConfig([in] struct UsbDev dev, [out] unsigned char configIndex);
+
+ /* *
+ * @brief Claims a USB interface exclusively. This must be done before data transfer.
+ *
+ * @param dev Indicates the USB device address.
+ * @param interfaceid Indicates the interface ID of the USB device.
+ * @param force Indicates whether to enable the force mode. The value 1 indicates that the force mode is
+ * enabled, and value 0 indicates the opposite.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ ClaimInterface([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] unsigned char force);
+
+ /* *
+ * @brief Manage a USB interface exclusively. Detach or attach the interface.
+ *
+ * @param dev Indicates the USB device address.
+ * @param interfaceid Indicates the interface ID of the USB device.
+ * @param disable Indicates whether to disable the interface.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ ManageInterface([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] boolean disable);
+
+ /* *
+ * @brief Releases a USB interface. This is usually done after data transfer.
+ *
+ * @param dev Indicates the USB device address.
+ * @param interfaceid Indicates the interface ID of the USB device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ ReleaseInterface([in] struct UsbDev dev, [in] unsigned char interfaceid);
+
+ /* *
+ * @brief Sets the alternate settings for the specified USB interface. This allows you to switch between two
+ * interfaces with the same ID but different alternate settings.
+ *
+ * @param dev Indicates the USB device address.
+ * @param interfaceid Indicates the interface ID of the USB device.
+ * @param altIndex Indicates the alternate settings of the USB interface.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ SetInterface([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] unsigned char altIndex);
+
+ /* *
+ * @brief Reads data on a specified endpoint during bulk transfer. The endpoint must be in the data reading
+ * direction. You can specify a timeout duration if needed.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param timeout Indicates the timeout duration.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @deprecated since 5.0
+ * @useinstead ohos.hdi.usb.v1_1.IUsbInterface.BulkTransferReadwithLength
+ */
+ BulkTransferRead([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data);
+
+ /* *
+ * @brief Writes data on a specified endpoint during bulk transfer. The endpoint must be in the data writing
+ * direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param timeout Indicates the timeout duration.
+ * @param data Indicates the written data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ BulkTransferWrite([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data);
+
+ /* *
+ * @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the
+ * request type. If the result of requestType&
+ * USB_ENDPOINT_DIR_MASK is USB_DIR_OUT, the endpoint is in the data writing direction; if the result
+ * is USB_DIR_IN, the endpoint is in the data reading direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param ctrl Indicates the control data packet structure.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @deprecated since 5.0
+ * @useinstead ohos.hdi.usb.v1_1.IUsbInterface.ControlTransferReadwithLength
+ */
+ ControlTransferRead([in] struct UsbDev dev, [in] struct UsbCtrlTransfer ctrl, [out] unsigned char[] data);
+
+ /* *
+ * @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the
+ * request type. If the result of requestType&
+ * USB_ENDPOINT_DIR_MASK is USB_DIR_OUT, the endpoint is in the data writing direction; if the result
+ * is USB_DIR_IN, the endpoint is in the data writing direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param ctrl Indicates the control data packet structure.
+ * @param data Indicates the write data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ ControlTransferWrite([in] struct UsbDev dev, [in] struct UsbCtrlTransfer ctrl, [in] unsigned char[] data);
+
+ /* *
+ * @brief Binds a subscriber.
+ *
+ * @param subscriber Indicates the subscriber.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ BindUsbdSubscriber([in] IUsbdSubscriber subscriber);
+
+ /* *
+ * @brief Unbinds a subscriber.
+ *
+ * @param subscriber Indicates the subscriber.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ UnbindUsbdSubscriber([in] IUsbdSubscriber subscriber);
+
+ /* *
+ * @brief Obtain the activation information of the USB device interface.
+ *
+ * @param dev Indicates the USB device address.
+ * @param interfaceid Indicates the interface ID of the USB device.
+ * @param unactivated Indicates whether the interface unactivated.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetInterfaceActiveStatus ([in] struct UsbDev dev, [in] unsigned char interfaceid, [out] boolean unactivated );
+
+ /* *
+ * @brief Obtains USB device speed.
+ *
+ * @param dev Indicates the USB device address.
+ * @param speed Indicates the USB device speed.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetDeviceSpeed([in] struct UsbDev dev, [out] unsigned char speed);
+
+ /* *
+ * @brief Reads data on a specified endpoint during bulk transfer. The endpoint must be in the data reading
+ * direction. You can specify a timeout duration if needed.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param timeout Indicates the timeout duration.
+ * @param length the maximum number of bytes to receive into the data buffer.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ BulkTransferReadwithLength([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] int length, [out] unsigned char[] data);
+
+ /* *
+ * @brief Obtains the file descriptor.
+ *
+ * @param dev Indicates the USB device address.
+ * @param fd USB device file descriptor
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ GetDeviceFileDescriptor([in] struct UsbDev dev, [out] FileDescriptor fd);
+
+ /* *
+ * @brief Clear the halt status for an endpoint.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ ClearHalt([in] struct UsbDev dev, [in] struct UsbPipe pipe);
+
+ /* *
+ * @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the
+ * request type. If the result of requestType&
+ * USB_ENDPOINT_DIR_MASK is USB_DIR_OUT, the endpoint is in the data writing direction; if the result
+ * is USB_DIR_IN, the endpoint is in the data reading direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param ctrl Indicates the control data packet structure.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ ControlTransferReadwithLength([in] struct UsbDev dev, [in] struct UsbCtrlTransferParams ctrl, [out] unsigned char[] data);
+
+ /* *
+ * @brief Reset device.
+ *
+ * @param dev Indicates the USB device address.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @version 2.0
+ */
+ ResetDevice([in] struct UsbDev dev);
+
+ /* *
+ * @brief Sends or receives requests for isochronous transfer on a specified endpoint. The data transfer direction
+ * is determined by the endpoint direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param clientData Indicates the client data.
+ * @param buffer Indicates the transferred data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ RequestQueue([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] unsigned char[] clientData, [in] unsigned char[] buffer);
+
+ /* *
+ * @brief Obtains the USB device descriptor.
+ *
+ * @param dev Indicates the USB device address.
+ * @param descriptor Indicates the USB device descriptor.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetDeviceDescriptor([in] struct UsbDev dev, [out] unsigned char[] descriptor);
+
+ /* *
+ * @brief Obtains the configuration descriptor of a USB device based on the specified config ID.
+ *
+ * @param dev Indicates the USB device address.
+ * @param descId Indicates configuration descriptor ID.
+ * @param descriptor Indicates the configuration descriptor of the USB device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ GetConfigDescriptor([in] struct UsbDev dev, [in] unsigned char descId, [out] unsigned char[] descriptor);
+
+ /* *
+ * @brief Obtains the file descriptor.
+ *
+ * @param dev Indicates the USB device address.
+ * @param fd USB device file descriptor
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ * @deprecated since 5.0
+ * @useinstead ohos.hdi.usb.v1_1.IUsbInterface.GetDeviceFileDescriptor
+ */
+ GetFileDescriptor([in] struct UsbDev dev, [out] int fd);
+
+ /* *
+ * @brief Reads data on a specified endpoint during interrupt transfer. The endpoint must be in the data reading
+ * direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param timeout Indicates the timeout duration.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ InterruptTransferRead([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data);
+
+ /* *
+ * @brief Writes data on a specified endpoint during interrupt transfer. The endpoint must be in the data writing
+ * direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param timeout Indicates the timeout duration.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ InterruptTransferWrite([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data);
+
+ /* *
+ * @brief Reads data on a specified endpoint during isochronous transfer. The endpoint must be in the data reading
+ * direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param timeout Indicates the timeout duration.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ IsoTransferRead([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data);
+
+ /* *
+ * @brief Writes data on a specified endpoint during isochronous transfer. The endpoint must be in the data writing
+ * direction.
+ *
+ * @param dev Indicates the USB device address.
+ * @param pipe Indicates the pipe of the USB device.
+ * @param timeout Indicates the timeout duration.
+ * @param data Indicates the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ IsoTransferWrite([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data);
+}
\ No newline at end of file
diff --git a/usb/v1_2/IUsbPortInterface.idl b/usb/v1_2/IUsbPortInterface.idl
new file mode 100644
index 0000000000000000000000000000000000000000..763e111708550cd9cb79ca764b77792fd70bc8a5
--- /dev/null
+++ b/usb/v1_2/IUsbPortInterface.idl
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* *
+ * @addtogroup HdiUsb
+ * @{
+ *
+ * @brief Provides unified APIs for usb services to access usb drivers.
+ *
+ * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to
+ * access different types of usb devices based on the usb IDs, thereby obtaining usb information,
+ * subscribing to or unsubscribing from usb data, enabling or disabling a usb,
+ * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range.
+ *
+ * @since 5.1
+ */
+
+/* *
+ * @file IUsbPortInterface.idl
+ *
+ * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or
+ * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode,
+ * and setting usb options such as the accuracy and measurement range.
+ *
+ * @since 5.1
+ * @version 2.0
+ */
+
+package ohos.hdi.usb.v1_2;
+
+import ohos.hdi.usb.v1_0.UsbTypes;
+import ohos.hdi.usb.v1_2.UsbTypes;
+import ohos.hdi.usb.v1_0.IUsbdSubscriber;
+import ohos.hdi.usb.v1_0.IUsbdBulkCallback;
+import ohos.hdi.usb.v1_0.IUsbInterface;
+
+/* *
+ * @brief Defines the functions for performing basic operations on usb.
+ *
+ * The operations include obtaining usb information, subscribing to or unsubscribing from usb data,
+ * enabling or disabling a usb, setting the usb data reporting mode, and setting usb options such as
+ * the accuracy and measurement range.
+ */
+interface IUsbPortInterface {
+
+ /* *
+ * @brief Closes a USB device to release all system resources related to the device.
+ *
+ * @param portId Indicates the port ID of the USB interface.
+ * @param powerRole Indicates the power role.
+ * @param dataRole Indicates the data role.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ SetPortRole([in] int portId, [in] int powerRole, [in] int dataRole);
+
+ /* *
+ * @brief Queries the current settings of a port.
+ *
+ * @param portId Indicates the port ID of the USB interface.
+ * @param powerRole Indicates the power role.
+ * @param dataRole Indicates the data role.
+ * @param mode Indicates the mode.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ QueryPort([out] int portId, [out] int powerRole, [out] int dataRole, [out] int mode);
+
+ /* *
+ * @brief Query the current settings of the device port list.
+ *
+ * @param portList is the detailed information of all ports on the current device.
+ *
+ * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails.
+ * @since 5.1
+ */
+ QueryPorts([out] struct UsbPort[] portList);
+}
\ No newline at end of file
diff --git a/usb/v1_2/UsbPortTypes.idl b/usb/v1_2/UsbPortTypes.idl
new file mode 100644
index 0000000000000000000000000000000000000000..d16b7647c52a2469a13eedd95cf8da81f2d8a68c
--- /dev/null
+++ b/usb/v1_2/UsbPortTypes.idl
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ /**
+ * @addtogroup HdiUsb
+ * @{
+ *
+ * @brief Provides unified APIs for usb services to access usb drivers.
+ *
+ * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to
+ * access different types of usb devices based on the usb IDs, thereby obtaining usb information,
+ * subscribing to or unsubscribing from usb data, enabling or disabling a usb,
+ * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range.
+ *
+ * @since 5.1
+ */
+
+/**
+ * @file UsbPortTypes.idl
+ *
+ * @brief Defines the data used by the usb module, including the usb information,
+ * and reported usb data.
+ *
+ * @since 5.1
+ * @version 2.0
+ */
+
+package ohos.hdi.usb.v1_2;
+
+struct UsbPortStatus {
+ int currentMode;
+ int currentPowerRole;
+ int currentDataRole;
+ int isConnected;
+ int supportedRoleCombinations;
+};
+
+struct UsbPort {
+ int id;
+ int supportedModes;
+ UsbPortStatus usbPortStatus;
+};
\ No newline at end of file