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 HdiUsbfnMtp 18 * @{ 19 * 20 * @brief Provides unified APIs for mtp services to access usb mtp/ptp drivers. 21 * 22 * A mtp service can obtain a usb mtp/ptp driver object or agent and then call APIs provided by this object or agent to 23 * transfer different types of mtp/ptp data packet. 24 * 25 * @since 4.0 26 */ 27 28/* * 29 * @file IUsbfnMtpInterface.idl 30 * 31 * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or 32 * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode, 33 * and setting usb options such as the accuracy and measurement range. 34 * 35 * @since 4.0 36 * @version 1.0 37 */ 38 39package ohos.hdi.usb.gadget.mtp.v1_0; 40 41import ohos.hdi.usb.gadget.mtp.v1_0.UsbfnMtpTypes; 42 43/* * 44 * @brief Defines the functions for performing basic operations on usb. 45 * 46 * The operations include obtaining usb information, subscribing to or unsubscribing from usb data, 47 * enabling or disabling a usb, setting the usb data reporting mode, and setting usb options such as 48 * the accuracy and measurement range. 49 */ 50interface IUsbfnMtpInterface { 51 52 /* * 53 * @brief Opens a USB MTP/PTP driver. 54 * 55 * @param None No parameter needed. 56 * 57 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 58 * @since 4.0 59 * @version 1.0 60 */ 61 Start(); 62 63 /* * 64 * @brief Closes a USB MTP/PTP driver. 65 * 66 * @param None No parameter needed. 67 * 68 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 69 * @since 4.0 70 * @version 1.0 71 */ 72 Stop(); 73 74 /* * 75 * @brief Read data by USB MTP/PTP driver. 76 * 77 * @param data Indicates the data read by USB MTP/PTP driver. 78 * 79 * @return Return number of bytes read, -1 or other negative value if the operation fails. 80 * @since 4.0 81 * @version 1.0 82 */ 83 Read([out] unsigned char[] data); 84 85 /* * 86 * @brief Write data by USB MTP/PTP driver. 87 * 88 * @param data Indicates the data write to USB MTP/PTP driver. 89 * 90 * @return Return number of bytes written, <b>-1</b> or other negative value if the operation fails. 91 * @since 4.0 92 * @version 1.0 93 */ 94 Write([in] unsigned char[] data); 95 96 /* * 97 * @brief Receive file by USB MTP/PTP driver. 98 * Proxy worked on file management, include fopen/fclose/fseek/fread/fwrite and offset infomation. 99 * Stub worked on data process. 100 * 101 * @param mfs Indicates the mtp file slice info. 102 * 103 * @return Returns <b>0</b> if receive is successful, <b>-1</b> or other negative value if the operation fails. 104 * @since 4.0 105 * @version 1.0 106 */ 107 ReceiveFile([in] struct UsbFnMtpFileSlice mfs); 108 109 /* * 110 * @brief Send file by USB MTP/PTP driver. 111 * Proxy worked on file management, include fopen/fclose/fseek/fread/fwrite and offset infomation. 112 * Stub worked on data process. 113 * 114 * @param mfs Indicates the mtp file range info, used is packet header. 115 * 116 * @return Returns <b>0</b> if send is successful, <b>-1</b> or other negative value if the operation fails. 117 * @since 4.0 118 * @version 1.0 119 */ 120 SendFile([in] struct UsbFnMtpFileSlice mfs); 121 122 /* * 123 * @brief Send event data by USB MTP/PTP driver. 124 * 125 * @param data Indicates the event data write to USB MTP/PTP driver. 126 * 127 * @return Returns <b>0</b> if send is successful, <b>-1</b> or other negative value if the operation fails. 128 * @since 4.0 129 * @version 1.0 130 */ 131 SendEvent([in] unsigned char[] eventData); 132 133 /* * 134 * @brief Init a USB MTP/PTP driver. Used by usb_host. 135 * 136 * @param None No parameter needed. 137 * 138 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 139 * @since 4.0 140 * @version 1.0 141 */ 142 Init(); 143 144 /* * 145 * @brief Release a USB MTP/PTP driver. Used by usb_host. 146 * 147 * @param None No parameter needed. 148 * 149 * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails. 150 * @since 4.0 151 * @version 1.0 152 */ 153 Release(); 154} 155