1/* 2 * Copyright (c) 2025 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 HdiUsb 18 * @{ 19 * 20 * @brief Provides unified APIs for usb services to access usb drivers. 21 * 22 * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to 23 * access different types of usb devices based on the usb IDs, thereby obtaining usb information, 24 * subscribing to or unsubscribing from usb data, enabling or disabling a usb, 25 * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. 26 * 27 * @since 5.1 28 * @version 1.0 29 */ 30 31/* * 32 * @file IUsbPortInterface.idl 33 * 34 * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or 35 * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode, 36 * and setting usb options such as the accuracy and measurement range. 37 * 38 * @since 5.1 39 * @version 1.0 40 */ 41 42package ohos.hdi.usb.v2_0; 43 44import ohos.hdi.usb.v2_0.UsbTypes; 45import ohos.hdi.usb.v2_0.IUsbdSubscriber; 46 47interface IUsbPortInterface { 48 49 /* * 50 * @brief Set the USB port role and data role. 51 * 52 * @param portId Indicates the port ID of the USB interface. 53 * @param powerRole Indicates the power role. 54 * @param dataRole Indicates the data role. 55 * 56 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 57 * @since 5.1 58 * @version 1.0 59 */ 60 SetPortRole([in] int portId, [in] int powerRole, [in] int dataRole); 61 62 /* * 63 * @brief Queries the current settings of a port. 64 * 65 * @param portId Indicates the port ID of the USB interface. 66 * @param powerRole Indicates the power role. 67 * @param dataRole Indicates the data role. 68 * @param mode Indicates the mode. 69 * 70 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 71 * @since 5.1 72 * @version 1.0 73 */ 74 QueryPort([out] int portId, [out] int powerRole, [out] int dataRole, [out] int mode); 75 76 /* * 77 * @brief Queries the current settings of all ports. 78 * 79 * @param portList Indicates the ports ID of the USB interface. 80 * 81 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 82 * @since 5.1 83 * @version 1.0 84 */ 85 QueryPorts([out] struct UsbPort[] portList); 86 87 /* * 88 * @brief Binds a subscriber. 89 * 90 * @param subscriber Indicates the subscriber. 91 * 92 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 93 * @since 5.1 94 * @version 1.0 95 */ 96 BindUsbdPortSubscriber([in] IUsbdSubscriber subscriber); 97 98 /* * 99 * @brief Unbinds a subscriber. 100 * 101 * @param subscriber Indicates the subscriber. 102 * 103 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 104 * @since 5.1 105 * @version 1.0 106 */ 107 UnbindUsbdPortSubscriber([in] IUsbdSubscriber subscriber); 108}