1/*
2 * Copyright (c) 2021 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 USB_HOST_NO_SDK_SPEED_H
17#define USB_HOST_NO_SDK_SPEED_H
18#include <stdint.h>
19#define USB_ADAPTER_URB_TYPE_ISO              0
20#define USB_ADAPTER_URB_TYPE_INTERRUPT        1
21#define USB_ADAPTER_URB_TYPE_CONTROL          2
22#define USB_ADAPTER_URB_TYPE_BULK             3
23#define USB_ADAPTER_URB_SHORT_NOT_OK          0x01
24#define USB_ADAPTER_URB_ISO_ASAP              0x02
25#define USB_ADAPTER_URB_BULK_CONTINUATION     0x04
26#define USB_ADAPTER_URB_QUEUE_BULK            0x10
27#define USB_ADAPTER_URB_ZERO_PACKET           0x40
28#define USB_ADAPTER_CAP_ZERO_PACKET           0x01
29#define USB_ADAPTER_CAP_BULK_CONTINUATION     0x02
30#define USB_ADAPTER_CAP_NO_PACKET_SIZE_LIM    0x04
31#define USB_ADAPTER_CAP_BULK_SCATTER_GATHER   0x08
32#define USB_ADAPTER_CAP_REAP_AFTER_DISCONNECT 0x10
33
34#define USBDEVFS_CLAIMINTERFACE   _IOR('U', 15, unsigned int)
35#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
36#define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
37#define USBDEVFS_SETINTERFACE     _IOR('U', 4, struct UsbSetInterface)
38#define USBDEVFS_ALLOC_STREAMS    _IOR('U', 28, struct UsbAdapterStreams)
39#define USBDEVFS_FREE_STREAMS     _IOR('U', 29, struct UsbAdapterStreams)
40#define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32)
41#define USBDEVFS_CLEAR_HALT       _IOR('U', 21, unsigned int)
42#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
43#define USBDEVFS_RESET            _IO('U', 20)
44#define USBDEVFS_CONTROL          _IOWR('U', 0, struct UsbCtrltransfer)
45#define USBDEVFS_DISCARDURB       _IO('U', 11)
46#define USBDEVFS_REAPURB          _IOW('U', 12, void *)
47#define USBDEVFS_SUBMITURB        _IOR('U', 10, struct UsbAdapterUrb)
48#define USBDEVFS_REAPURBNDELAY    _IOW('U', 13, void *)
49
50typedef enum {
51    TEST_ZERO_TYPE = 0,
52    TEST_ONE_TYPE,
53    TEST_TWO_TYPE,
54    TEST_THREE_TYPE,
55    TEST_FOUR_TYPE,
56    TEST_FIVE_TYPE,
57    TEST_SIX_TYPE,
58} TestCountType;
59
60struct UsbIsoPacketDesc {
61    unsigned int length;
62    unsigned int actualLength;
63    unsigned int status;
64};
65
66struct UsbAdapterUrb {
67    unsigned char type;
68    unsigned char endPoint;
69    int32_t status;
70    unsigned int flags;
71    void *buffer;
72    int32_t bufferLength;
73    int32_t actualLength;
74    int32_t startFrame;
75    union {
76        int32_t numberOfPackets;
77        unsigned int streamId;
78    };
79    int32_t errorCount;
80    unsigned int signr;
81    void *userContext;
82    struct UsbIsoPacketDesc isoFrameDesc[0];
83};
84
85struct UsbAdapterUrbs {
86    struct UsbAdapterUrb *urb;
87    int32_t inUse;
88    int32_t urbNum;
89};
90
91#endif /* USB_HOST_NO_SDK_SPEED_H */
92