1c5e268c6Sopenharmony_ci/*
2c5e268c6Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3c5e268c6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c5e268c6Sopenharmony_ci * you may not use this file except in compliance with the License.
5c5e268c6Sopenharmony_ci * You may obtain a copy of the License at
6c5e268c6Sopenharmony_ci *
7c5e268c6Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c5e268c6Sopenharmony_ci *
9c5e268c6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c5e268c6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c5e268c6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c5e268c6Sopenharmony_ci * See the License for the specific language governing permissions and
13c5e268c6Sopenharmony_ci * limitations under the License.
14c5e268c6Sopenharmony_ci */
15c5e268c6Sopenharmony_ci
16c5e268c6Sopenharmony_ci/* *
17c5e268c6Sopenharmony_ci * @addtogroup HdiUsbfnMtp
18c5e268c6Sopenharmony_ci * @{
19c5e268c6Sopenharmony_ci *
20c5e268c6Sopenharmony_ci * @brief Provides unified APIs for mtp services to access usb mtp/ptp drivers.
21c5e268c6Sopenharmony_ci *
22c5e268c6Sopenharmony_ci * A mtp service can obtain a usb mtp/ptp driver object or agent and then call APIs provided by this object or agent to
23c5e268c6Sopenharmony_ci * transfer different types of mtp/ptp data packet.
24c5e268c6Sopenharmony_ci *
25c5e268c6Sopenharmony_ci * @since 4.0
26c5e268c6Sopenharmony_ci */
27c5e268c6Sopenharmony_ci
28c5e268c6Sopenharmony_ci/* *
29c5e268c6Sopenharmony_ci * @file IUsbfnMtpInterface.idl
30c5e268c6Sopenharmony_ci *
31c5e268c6Sopenharmony_ci * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or
32c5e268c6Sopenharmony_ci * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode,
33c5e268c6Sopenharmony_ci * and setting usb options such as the accuracy and measurement range.
34c5e268c6Sopenharmony_ci *
35c5e268c6Sopenharmony_ci * @since 4.0
36c5e268c6Sopenharmony_ci * @version 1.0
37c5e268c6Sopenharmony_ci */
38c5e268c6Sopenharmony_ci
39c5e268c6Sopenharmony_cipackage ohos.hdi.usb.gadget.mtp.v1_0;
40c5e268c6Sopenharmony_ci
41c5e268c6Sopenharmony_ciimport ohos.hdi.usb.gadget.mtp.v1_0.UsbfnMtpTypes;
42c5e268c6Sopenharmony_ci
43c5e268c6Sopenharmony_ci/* *
44c5e268c6Sopenharmony_ci * @brief Defines the functions for performing basic operations on usb.
45c5e268c6Sopenharmony_ci *
46c5e268c6Sopenharmony_ci * The operations include obtaining usb information, subscribing to or unsubscribing from usb data,
47c5e268c6Sopenharmony_ci * enabling or disabling a usb, setting the usb data reporting mode, and setting usb options such as
48c5e268c6Sopenharmony_ci * the accuracy and measurement range.
49c5e268c6Sopenharmony_ci */
50c5e268c6Sopenharmony_ciinterface IUsbfnMtpInterface {
51c5e268c6Sopenharmony_ci
52c5e268c6Sopenharmony_ci    /* *
53c5e268c6Sopenharmony_ci     * @brief Opens a USB MTP/PTP driver.
54c5e268c6Sopenharmony_ci     *
55c5e268c6Sopenharmony_ci     * @param None No parameter needed.
56c5e268c6Sopenharmony_ci     *
57c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
58c5e268c6Sopenharmony_ci     * @since 4.0
59c5e268c6Sopenharmony_ci     * @version 1.0
60c5e268c6Sopenharmony_ci     */
61c5e268c6Sopenharmony_ci    Start();
62c5e268c6Sopenharmony_ci
63c5e268c6Sopenharmony_ci    /* *
64c5e268c6Sopenharmony_ci     * @brief Closes a USB MTP/PTP driver.
65c5e268c6Sopenharmony_ci     *
66c5e268c6Sopenharmony_ci     * @param None No parameter needed.
67c5e268c6Sopenharmony_ci     *
68c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
69c5e268c6Sopenharmony_ci     * @since 4.0
70c5e268c6Sopenharmony_ci     * @version 1.0
71c5e268c6Sopenharmony_ci     */
72c5e268c6Sopenharmony_ci    Stop();
73c5e268c6Sopenharmony_ci
74c5e268c6Sopenharmony_ci    /* *
75c5e268c6Sopenharmony_ci     * @brief Read data by USB MTP/PTP driver.
76c5e268c6Sopenharmony_ci     *
77c5e268c6Sopenharmony_ci     * @param data Indicates the data read by USB MTP/PTP driver.
78c5e268c6Sopenharmony_ci     *
79c5e268c6Sopenharmony_ci     * @return Return number of bytes read, -1 or other negative value if the operation fails.
80c5e268c6Sopenharmony_ci     * @since 4.0
81c5e268c6Sopenharmony_ci     * @version 1.0
82c5e268c6Sopenharmony_ci     */
83c5e268c6Sopenharmony_ci    Read([out] unsigned char[] data);
84c5e268c6Sopenharmony_ci
85c5e268c6Sopenharmony_ci    /* *
86c5e268c6Sopenharmony_ci     * @brief Write data by USB MTP/PTP driver.
87c5e268c6Sopenharmony_ci     *
88c5e268c6Sopenharmony_ci     * @param data Indicates the data write to USB MTP/PTP driver.
89c5e268c6Sopenharmony_ci     *
90c5e268c6Sopenharmony_ci     * @return Return number of bytes written, <b>-1</b> or other negative value if the operation fails.
91c5e268c6Sopenharmony_ci     * @since 4.0
92c5e268c6Sopenharmony_ci     * @version 1.0
93c5e268c6Sopenharmony_ci     */
94c5e268c6Sopenharmony_ci    Write([in] unsigned char[] data);
95c5e268c6Sopenharmony_ci
96c5e268c6Sopenharmony_ci    /* *
97c5e268c6Sopenharmony_ci     * @brief Receive file by USB MTP/PTP driver.
98c5e268c6Sopenharmony_ci     * Proxy worked on file management, include fopen/fclose/fseek/fread/fwrite and offset infomation.
99c5e268c6Sopenharmony_ci     * Stub worked on data process.
100c5e268c6Sopenharmony_ci     *
101c5e268c6Sopenharmony_ci     * @param mfs Indicates the mtp file slice info.
102c5e268c6Sopenharmony_ci     *
103c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if receive is successful, <b>-1</b> or other negative value if the operation fails.
104c5e268c6Sopenharmony_ci     * @since 4.0
105c5e268c6Sopenharmony_ci     * @version 1.0
106c5e268c6Sopenharmony_ci     */
107c5e268c6Sopenharmony_ci    ReceiveFile([in] struct UsbFnMtpFileSlice mfs);
108c5e268c6Sopenharmony_ci
109c5e268c6Sopenharmony_ci    /* *
110c5e268c6Sopenharmony_ci     * @brief Send file by USB MTP/PTP driver.
111c5e268c6Sopenharmony_ci     * Proxy worked on file management, include fopen/fclose/fseek/fread/fwrite and offset infomation.
112c5e268c6Sopenharmony_ci     * Stub worked on data process.
113c5e268c6Sopenharmony_ci     *
114c5e268c6Sopenharmony_ci     * @param mfs Indicates the mtp file range info, used is packet header.
115c5e268c6Sopenharmony_ci     *
116c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if send is successful, <b>-1</b> or other negative value if the operation fails.
117c5e268c6Sopenharmony_ci     * @since 4.0
118c5e268c6Sopenharmony_ci     * @version 1.0
119c5e268c6Sopenharmony_ci     */
120c5e268c6Sopenharmony_ci    SendFile([in] struct UsbFnMtpFileSlice mfs);
121c5e268c6Sopenharmony_ci
122c5e268c6Sopenharmony_ci    /* *
123c5e268c6Sopenharmony_ci     * @brief Send event data by USB MTP/PTP driver.
124c5e268c6Sopenharmony_ci     *
125c5e268c6Sopenharmony_ci     * @param data Indicates the event data write to USB MTP/PTP driver.
126c5e268c6Sopenharmony_ci     *
127c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if send is successful, <b>-1</b> or other negative value if the operation fails.
128c5e268c6Sopenharmony_ci     * @since 4.0
129c5e268c6Sopenharmony_ci     * @version 1.0
130c5e268c6Sopenharmony_ci     */
131c5e268c6Sopenharmony_ci    SendEvent([in] unsigned char[] eventData);
132c5e268c6Sopenharmony_ci
133c5e268c6Sopenharmony_ci    /* *
134c5e268c6Sopenharmony_ci     * @brief Init a USB MTP/PTP driver. Used by usb_host.
135c5e268c6Sopenharmony_ci     *
136c5e268c6Sopenharmony_ci     * @param None No parameter needed.
137c5e268c6Sopenharmony_ci     *
138c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
139c5e268c6Sopenharmony_ci     * @since 4.0
140c5e268c6Sopenharmony_ci     * @version 1.0
141c5e268c6Sopenharmony_ci     */
142c5e268c6Sopenharmony_ci    Init();
143c5e268c6Sopenharmony_ci
144c5e268c6Sopenharmony_ci    /* *
145c5e268c6Sopenharmony_ci     * @brief Release a USB MTP/PTP driver. Used by usb_host.
146c5e268c6Sopenharmony_ci     *
147c5e268c6Sopenharmony_ci     * @param None No parameter needed.
148c5e268c6Sopenharmony_ci     *
149c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
150c5e268c6Sopenharmony_ci     * @since 4.0
151c5e268c6Sopenharmony_ci     * @version 1.0
152c5e268c6Sopenharmony_ci     */
153c5e268c6Sopenharmony_ci    Release();
154c5e268c6Sopenharmony_ci}
155