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#ifndef OHOS_HDI_USB_DDK_V1_0_USBDDKSERVICE_H
17#define OHOS_HDI_USB_DDK_V1_0_USBDDKSERVICE_H
18
19#include "v1_0/iusb_ddk.h"
20
21namespace OHOS {
22namespace HDI {
23namespace Usb {
24namespace Ddk {
25namespace V1_0 {
26class UsbDdkService : public OHOS::HDI::Usb::Ddk::V1_0::IUsbDdk {
27public:
28    UsbDdkService() = default;
29    virtual ~UsbDdkService() = default;
30
31    int32_t Init() override;
32
33    int32_t Release() override;
34
35    int32_t GetDeviceDescriptor(uint64_t deviceId, OHOS::HDI::Usb::Ddk::V1_0::UsbDeviceDescriptor& desc) override;
36
37    int32_t GetConfigDescriptor(uint64_t deviceId, uint8_t configIndex, std::vector<uint8_t>& configDesc) override;
38
39    int32_t ClaimInterface(uint64_t deviceId, uint8_t interfaceIndex, uint64_t& interfaceHandle) override;
40
41    int32_t ReleaseInterface(uint64_t interfaceHandle) override;
42
43    int32_t SelectInterfaceSetting(uint64_t interfaceHandle, uint8_t settingIndex) override;
44
45    int32_t GetCurrentInterfaceSetting(uint64_t interfaceHandle, uint8_t& settingIndex) override;
46
47    int32_t SendControlReadRequest(uint64_t interfaceHandle,
48         const OHOS::HDI::Usb::Ddk::V1_0::UsbControlRequestSetup& setup, uint32_t timeout, std::vector<uint8_t>& data) override;
49
50    int32_t SendControlWriteRequest(uint64_t interfaceHandle,
51         const OHOS::HDI::Usb::Ddk::V1_0::UsbControlRequestSetup& setup, uint32_t timeout, const std::vector<uint8_t>& data) override;
52
53    int32_t SendPipeRequest(const OHOS::HDI::Usb::Ddk::V1_0::UsbRequestPipe& pipe, uint32_t size, uint32_t offset,
54         uint32_t length, uint32_t& transferedLength) override;
55
56    int32_t GetDeviceMemMapFd(uint64_t deviceId, int& fd) override;
57
58};
59} // V1_0
60} // Ddk
61} // Usb
62} // HDI
63} // OHOS
64
65#endif // OHOS_HDI_USB_DDK_V1_0_USBDDKSERVICE_H
66
67