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 #include <hdf_log.h>
17 #include "usbd_wrapper.h"
18 #include "usb_transfer_callback.h"
19 #define HDF_LOG_TAG UsbTransferCb
20
21 namespace OHOS {
22 namespace HDI {
23 namespace Usb {
24 namespace V2_0 {
25
OnTransferWriteCallback(int32_t status,int32_t actLength,const std::vector<HDI::Usb::V1_2::UsbIsoPacketDescriptor> & isoInfo,const uint64_t userData)26 int32_t UsbTransferCb::OnTransferWriteCallback(int32_t status, int32_t actLength,
27 const std::vector<HDI::Usb::V1_2::UsbIsoPacketDescriptor> &isoInfo, const uint64_t userData)
28 {
29 HDF_LOGD("%{public}s: enter", __func__);
30 if (transferCallback_ == nullptr) {
31 HDF_LOGE("%{public}s: transferCallback_ is nullptr", __func__);
32 return HDF_FAILURE;
33 }
34 const std::vector<V2_0::UsbIsoPacketDescriptor> &UsbInfo =
35 reinterpret_cast<const std::vector<V2_0::UsbIsoPacketDescriptor> &>(isoInfo);
36 return transferCallback_->OnTransferWriteCallback(status, actLength, UsbInfo, userData);
37 }
38
OnTransferReadCallback(int32_t status,int32_t actLength,const std::vector<HDI::Usb::V1_2::UsbIsoPacketDescriptor> & isoInfo,const uint64_t userData)39 int32_t UsbTransferCb::OnTransferReadCallback(int32_t status, int32_t actLength,
40 const std::vector<HDI::Usb::V1_2::UsbIsoPacketDescriptor> &isoInfo, const uint64_t userData)
41 {
42 HDF_LOGD("%{public}s: enter", __func__);
43 if (transferCallback_ == nullptr) {
44 HDF_LOGE("%{public}s: transferCallback_ is nullptr", __func__);
45 return HDF_FAILURE;
46 }
47 const std::vector<V2_0::UsbIsoPacketDescriptor> &UsbInfo =
48 reinterpret_cast<const std::vector<V2_0::UsbIsoPacketDescriptor> &>(isoInfo);
49 return transferCallback_->OnTransferReadCallback(status, actLength, UsbInfo, userData);
50 }
51
52 } // V2_0
53 } // Usb
54 } // HDI
55 } // OHOS
56