• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "usb_raw_test.h"
10 #include "data_fifo.h"
11 #include "device_resource_if.h"
12 #include "hdf_base.h"
13 #include "hdf_device_desc.h"
14 #include "hdf_dlist.h"
15 #include "hdf_log.h"
16 #include "osal_mem.h"
17 #include "osal_time.h"
18 #include "usb_ddk_interface.h"
19 #ifdef LOSCFG_DRIVERS_HDF_USB_PNP_NOTIFY
20 #include "usb_pnp_notify.h"
21 #endif
22 
23 bool g_writeBufFlag = 0;
24 struct UsbSession *g_session = NULL;
25 struct AcmRawDevice g_deviceService;
26 struct AcmRawDevice *g_acm = &g_deviceService;
27 UsbRawHandle *g_devHandle = NULL;
28 UsbRawDevice *g_dev = NULL;
29 int32_t g_activeConfig;
30 bool g_initFlag;
31 bool g_stopIoThreadFlag = false;
32 
UsbGetIoAcm(void)33 struct AcmRawDevice *UsbGetIoAcm(void)
34 {
35     return g_acm;
36 }
37 
UsbIoThread(void * data)38 int32_t UsbIoThread(void *data)
39 {
40     int32_t ret;
41     struct AcmRawDevice *acm = (struct AcmRawDevice *)data;
42 
43     while (true) {
44         printf("%s:%d\n", __func__, __LINE__);
45         if (acm == NULL) {
46             printf("%s:%d acm is NULL\n", __func__, __LINE__);
47             OsalMSleep(USB_RAW_IO_SLEEP_MS_TIME);
48             continue;
49         }
50 
51         if (acm->devHandle == NULL) {
52             printf("%s:%d acm->devHandle is NULL!\n", __func__, __LINE__);
53             OsalMSleep(USB_RAW_IO_SLEEP_MS_TIME);
54             continue;
55         }
56 
57         printf("%s:%d\n", __func__, __LINE__);
58         ret = UsbRawHandleRequests(acm->devHandle);
59         printf("%s:%d, ret=%d\n", __func__, __LINE__, ret);
60         if (ret < 0) {
61             printf("%s:%d UsbRawHandleRequests faile, ret=%d \n", __func__, __LINE__, ret);
62             if (ret == HDF_DEV_ERR_NO_DEVICE) {
63                 printf("%s:%d, ret=%d\n", __func__, __LINE__, ret);
64                 OsalMSleep(USB_RAW_IO_SLEEP_MS_TIME);
65             }
66         }
67 
68         if (g_stopIoThreadFlag == true) {
69             printf("%s:%d\n", __func__, __LINE__);
70             break;
71         }
72     }
73 
74     printf("%s:%d exit\n", __func__, __LINE__);
75 
76     return HDF_SUCCESS;
77 }
78 
79 
UsbStartIo(void)80 int32_t UsbStartIo(void)
81 {
82     struct OsalThreadParam threadCfg;
83     int32_t ret;
84 
85     printf("%s start\n", __func__);
86     g_stopIoThreadFlag = false;
87 
88     /* create Io thread */
89     (void)memset_s(&threadCfg, sizeof(threadCfg), 0, sizeof(threadCfg));
90     threadCfg.name      = (char *)("usb io thread");
91     threadCfg.priority  = OSAL_THREAD_PRI_LOW;
92     threadCfg.stackSize = USB_IO_THREAD_STACK_SIZE;
93 
94     ret = OsalThreadCreate(&g_acm->ioThread, \
95                            (OsalThreadEntry)UsbIoThread, (void *)g_acm);
96     if (ret != HDF_SUCCESS) {
97         printf("%s:%d OsalThreadCreate faile, ret=%d \n", __func__, __LINE__, ret);
98         return ret;
99     }
100 
101     ret = OsalThreadStart(&g_acm->ioThread, &threadCfg);
102     if (ret != HDF_SUCCESS) {
103         printf("%s:%d OsalThreadStart faile, ret=%d \n", __func__, __LINE__, ret);
104         return ret;
105     }
106 
107     return HDF_SUCCESS;
108 }
109 
UsbStopIo(void)110 int32_t UsbStopIo(void)
111 {
112     int32_t ret;
113     g_stopIoThreadFlag = true;
114     HDF_LOGD("%s:%d", __func__, __LINE__);
115     ret = OsalThreadDestroy(&g_acm->ioThread);
116     if (ret != HDF_SUCCESS) {
117         HDF_LOGE("%s:%d OsalThreadDestroy faile, ret=%d ", __func__, __LINE__, ret);
118         return ret;
119     }
120     return HDF_SUCCESS;
121 }
122 
AcmWriteBulkCallback(const void * requestArg)123 void AcmWriteBulkCallback(const void *requestArg)
124 {
125     struct UsbRawRequest *req = (struct UsbRawRequest *)requestArg;
126 
127     printf("%s:%d entry!", __func__, __LINE__);
128 
129     if (req == NULL) {
130         printf("%s:%d req is NULL!", __func__, __LINE__);
131         return;
132     }
133     struct RawWb *wb  = (struct RawWb *)req->userData;
134     if (wb == NULL) {
135         printf("%s:%d userData(wb) is NULL!", __func__, __LINE__);
136         return;
137     }
138 
139     if (req->status != USB_REQUEST_COMPLETED) {
140         printf("%s: write req failed, status=%d", __func__, req->status);
141     }
142 
143     wb->use = 0;
144 }
145 
AcmWriteIsoCallback(const void * requestArg)146 void AcmWriteIsoCallback(const void *requestArg)
147 {
148     struct UsbRawRequest *req = (struct UsbRawRequest *)requestArg;
149     printf("%s:%d status:%d\n", __func__, __LINE__, req->status);
150 }
151 
AcmReadBulkCallback(const void * requestArg)152 void AcmReadBulkCallback(const void *requestArg)
153 {
154     struct UsbRawRequest *req = (struct UsbRawRequest *)requestArg;
155 
156     printf("%s:%d entry!", __func__, __LINE__);
157 
158     if (req == NULL) {
159         printf("%s:%d req is NULL!", __func__, __LINE__);
160         return;
161     }
162     struct AcmRawDevice *acm = (struct AcmRawDevice *)req->userData;
163     if (acm == NULL) {
164         printf("%s:%d userData(acm) is NULL!", __func__, __LINE__);
165         return;
166     }
167     size_t size = (size_t)req->actualLength;
168 
169     switch (req->status) {
170         case USB_REQUEST_COMPLETED:
171             HDF_LOGD("Bulk status: %d+size:%u\n", req->status, size);
172             if (size) {
173                 uint8_t *data = req->buffer;
174                 printf("rcv:%s\n", (char *)data);
175             }
176             break;
177         case USB_REQUEST_CANCELLED:
178             return;
179         default:
180             printf("%s: the request is failed\n", __func__);
181             break;
182     }
183 
184     if (UsbRawSubmitRequest(req) != HDF_SUCCESS) {
185         printf("%s - UsbRawSubmitRequest failed", __func__);
186     }
187 }
188 
AcmNotifyReqCallback(const void * requestArg)189 void AcmNotifyReqCallback(const void *requestArg)
190 {
191     struct UsbRawRequest *req = (struct UsbRawRequest *)requestArg;
192 
193     printf("%s:%d entry!", __func__, __LINE__);
194 
195     if (req == NULL) {
196         printf("%s:%d req is NULL!", __func__, __LINE__);
197         return;
198     }
199     struct AcmRawDevice *acm = (struct AcmRawDevice *)req->userData;
200     if (acm == NULL) {
201         printf("%s:%d userData(acm) is NULL!", __func__, __LINE__);
202         return;
203     }
204     struct UsbCdcNotification *dr = (struct UsbCdcNotification *)req->buffer;
205     if (dr == NULL) {
206         printf("%s:%d req->buffer(dr) is NULL!", __func__, __LINE__);
207         return;
208     }
209     unsigned int currentSize = req->actualLength;
210 
211     printf("Irqstatus:%d,actualLength:%u\n", req->status, currentSize);
212 }
213 
AcmWriteBufAllocHandle(const struct AcmRawDevice * acm)214 static int32_t AcmWriteBufAllocHandle(const struct AcmRawDevice *acm)
215 {
216     int32_t i;
217     struct RawWb *wb;
218     for (wb = (struct RawWb *)&acm->wb[0], i = 0; i < ACM_NW; i++, wb++) {
219         wb->buf = OsalMemCalloc(acm->dataOutEp.maxPacketSize);
220         if (!wb->buf) {
221             while (i > 0) {
222                 --i;
223                 --wb;
224                 OsalMemFree(wb->buf);
225                 wb->buf = NULL;
226             }
227             return -HDF_ERR_MALLOC_FAIL;
228         }
229         g_writeBufFlag = true;
230     }
231 
232     return HDF_SUCCESS;
233 }
234 
AcmWriteBufAlloc(struct AcmRawDevice * acm)235 int32_t AcmWriteBufAlloc(struct AcmRawDevice *acm)
236 {
237     int32_t ret = HDF_SUCCESS;
238 
239     if (!g_writeBufFlag) {
240         ret = AcmWriteBufAllocHandle(acm);
241     }
242 
243     return ret;
244 }
245 
AcmWriteBufFree(struct AcmRawDevice * acm)246 void AcmWriteBufFree(struct AcmRawDevice *acm)
247 {
248     int32_t i;
249     struct RawWb *wb;
250     for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++) {
251         if (wb->buf) {
252             OsalMemFree(wb->buf);
253             wb->buf = NULL;
254         }
255     }
256     g_writeBufFlag = false;
257     return;
258 }
259 
AcmCtrlReqCallback(const void * requestArg)260 void AcmCtrlReqCallback(const void *requestArg)
261 {
262     (void)requestArg;
263     HDF_LOGI("%{public}s:%{public}d entry!", __func__, __LINE__);
264 }
265 
AcmParaseInterfaceClass(struct AcmRawDevice * const acm,const struct UsbRawInterface * interface,uint8_t number)266 static void AcmParaseInterfaceClass(
267     struct AcmRawDevice * const acm, const struct UsbRawInterface *interface, uint8_t number)
268 {
269     uint8_t ifaceClass;
270     uint8_t numEndpoints;
271 
272     ifaceClass = interface->altsetting->interfaceDescriptor.bInterfaceClass;
273     numEndpoints = interface->altsetting->interfaceDescriptor.bNumEndpoints;
274 
275     switch (ifaceClass) {
276         case USB_DDK_CLASS_COMM:
277             acm->ctrlIface = number;
278             /* get the first endpoint  by default */
279             acm->notifyEp.addr = interface->altsetting->endPoint[0].endpointDescriptor.bEndpointAddress;
280             acm->notifyEp.interval = interface->altsetting->endPoint[0].endpointDescriptor.bInterval;
281             acm->notifyEp.maxPacketSize = interface->altsetting->endPoint[0].endpointDescriptor.wMaxPacketSize;
282             break;
283         case USB_DDK_CLASS_CDC_DATA:
284             acm->dataIface = number;
285             for (uint8_t j = 0; j < numEndpoints; j++) {
286                 const struct UsbRawEndpointDescriptor *endPoint = &interface->altsetting->endPoint[j];
287 
288                 /* get bulk in endpoint  */
289                 if ((endPoint->endpointDescriptor.bEndpointAddress
290                     & USB_DDK_ENDPOINT_DIR_MASK) == USB_DDK_DIR_IN) {
291                     acm->dataInEp.addr = endPoint->endpointDescriptor.bEndpointAddress;
292                     acm->dataInEp.interval = endPoint->endpointDescriptor.bInterval;
293                     acm->dataInEp.maxPacketSize = endPoint->endpointDescriptor.wMaxPacketSize;
294                 } else { /* get bulk out endpoint  */
295                     acm->dataOutEp.addr = endPoint->endpointDescriptor.bEndpointAddress;
296                     acm->dataOutEp.interval = endPoint->endpointDescriptor.bInterval;
297                     acm->dataOutEp.maxPacketSize = endPoint->endpointDescriptor.wMaxPacketSize;
298                 }
299             }
300             break;
301         default:
302             printf("%s:%d wrong descriptor type\n", __func__, __LINE__);
303             break;
304     }
305 }
306 
UsbParseConfigDescriptor(struct AcmRawDevice * acm,struct UsbRawConfigDescriptor * config)307 int32_t UsbParseConfigDescriptor(struct AcmRawDevice *acm, struct UsbRawConfigDescriptor *config)
308 {
309     uint8_t numInterfaces;
310     const struct UsbRawInterface *interface = NULL;
311 
312     numInterfaces = config->configDescriptor.bNumInterfaces;
313     printf("------numInterfaces = [%hhu]------\n", numInterfaces);
314     for (uint8_t i = 0; i < numInterfaces; i++) {
315         interface = config->interface[i];
316 
317         printf("------UsbRawClaimInterface start------\n");
318         int32_t ret = UsbRawClaimInterface(acm->devHandle, i);
319         if (ret != HDF_SUCCESS) {
320             printf("%s:%d claim interface %hhu failed\n", __func__, __LINE__, i);
321             continue;
322         }
323         printf("------UsbRawClaimInterface end------\n");
324         AcmParaseInterfaceClass(acm, interface, i);
325     }
326 
327     return HDF_SUCCESS;
328 }
329 
330 
331 struct UsbRawTestFunc g_usbRawFunc[] = {
332     { USB_RAW_SDK_IF_START_IO, UsbStartIo},
333     { USB_RAW_SDK_IF_INIT_001_TEST, CheckRawSdkIfInit001},
334     { USB_RAW_SDK_IF_EXIT_001_TEST, CheckRawSdkIfExit001},
335     { USB_RAW_SDK_IF_INIT_002_TEST, CheckRawSdkIfInit002},
336     { USB_RAW_SDK_IF_EXIT_002_TEST, CheckRawSdkIfExit002},
337     { USB_RAW_SDK_IF_INIT_003_TEST, CheckRawSdkIfInit003},
338     { USB_RAW_SDK_IF_INIT_004_TEST, CheckRawSdkIfInit004},
339     { USB_RAW_SDK_IF_INIT_005_TEST, CheckRawSdkIfInit005},
340     { USB_RAW_SDK_IF_OPEN_DEVICE_001_TEST, CheckRawSdkIfOpenDevice001},
341     { USB_RAW_SDK_IF_OPEN_DEVICE_002_TEST, CheckRawSdkIfOpenDevice002},
342     { USB_RAW_SDK_IF_OPEN_DEVICE_003_TEST, CheckRawSdkIfOpenDevice003},
343     { USB_RAW_SDK_IF_OPEN_DEVICE_004_TEST, CheckRawSdkIfOpenDevice004},
344     { USB_RAW_SDK_IF_OPEN_DEVICE_005_TEST, CheckRawSdkIfOpenDevice005},
345     { USB_RAW_SDK_IF_OPEN_DEVICE_006_TEST, CheckRawSdkIfOpenDevice006},
346     { USB_RAW_SDK_IF_RESET_DEVICE_001_TEST, CheckRawSdkIfResetDevice001},
347     { USB_RAW_SDK_IF_RESET_DEVICE_002_TEST, CheckRawSdkIfResetDevice002},
348     { USB_RAW_SDK_IF_CLOSE_DEVICE_001_TEST, CheckRawSdkIfCloseDevice001},
349     { USB_RAW_SDK_IF_CLOSE_DEVICE_002_TEST, CheckRawSdkIfCloseDevice002},
350     { USB_RAW_SDK_IF_OPEN_DEVICE_007_TEST, CheckRawSdkIfOpenDevice007},
351     { USB_RAW_SDK_IF_GET_CONFIGURATION_001_TEST, CheckRawSdkIfGetConfiguration001},
352     { USB_RAW_SDK_IF_GET_CONFIGURATION_002_TEST, CheckRawSdkIfGetConfiguration002},
353     { USB_RAW_SDK_IF_GET_CONFIGURATION_003_TEST, CheckRawSdkIfGetConfiguration003},
354     { USB_RAW_SDK_IF_GET_CONFIGURATION_004_TEST, CheckRawSdkIfGetConfiguration004},
355     { USB_RAW_SDK_IF_GET_DEVICE_001_TEST, CheckRawSdkIfGetDevice001},
356     { USB_RAW_SDK_IF_GET_DEVICE_002_TEST, CheckRawSdkIfGetDevice002},
357     { USB_RAW_SDK_IF_GET_CONFIG_DESC_001_TEST, CheckRawSdkIfGetConfigDescriptor001},
358     { USB_RAW_SDK_IF_GET_CONFIG_DESC_002_TEST, CheckRawSdkIfGetConfigDescriptor002},
359     { USB_RAW_SDK_IF_GET_CONFIG_DESC_003_TEST, CheckRawSdkIfGetConfigDescriptor003},
360     { USB_RAW_SDK_IF_GET_CONFIG_DESC_004_TEST, CheckRawSdkIfGetConfigDescriptor004},
361     { USB_RAW_SDK_IF_SET_CONFIGURATION_001_TEST, CheckRawSdkIfSetConfiguration001},
362     { USB_RAW_SDK_IF_SET_CONFIGURATION_002_TEST, CheckRawSdkIfSetConfiguration002},
363     { USB_RAW_SDK_IF_SET_CONFIGURATION_003_TEST, CheckRawSdkIfSetConfiguration003},
364     { USB_RAW_SDK_IF_SET_CONFIGURATION_004_TEST, CheckRawSdkIfSetConfiguration004},
365     { USB_RAW_SDK_IF_SET_CONFIGURATION_005_TEST, CheckRawSdkIfSetConfiguration005},
366     { USB_RAW_SDK_IF_SET_CONFIGURATION_006_TEST, CheckRawSdkIfSetConfiguration006},
367     { USB_RAW_SDK_IF_SET_CONFIGURATION_007_TEST, CheckRawSdkIfSetConfiguration007},
368     { USB_RAW_SDK_IF_SET_CONFIGURATION_008_TEST, CheckRawSdkIfSetConfiguration008},
369     { USB_RAW_SDK_IF_GET_DEVICE_DESC_001_TEST, CheckRawSdkIfGetDeviceDescriptor001},
370     { USB_RAW_SDK_IF_GET_DEVICE_DESC_002_TEST, CheckRawSdkIfGetDeviceDescriptor002},
371     { USB_RAW_SDK_IF_GET_DEVICE_DESC_003_TEST, CheckRawSdkIfGetDeviceDescriptor003},
372     { USB_RAW_SDK_IF_GET_DEVICE_DESC_004_TEST, CheckRawSdkIfGetDeviceDescriptor004},
373     { USB_RAW_SDK_IF_GET_CONFIG_DESC_005_TEST, CheckRawSdkIfGetConfigDescriptor005},
374     { USB_RAW_SDK_IF_GET_DEVICE_DESC_005_TEST, CheckRawSdkIfGetDeviceDescriptor005},
375     { USB_RAW_SDK_IF_CLAMIN_INTERFACE_001_TEST, CheckRawSdkIfClaimInterface001},
376     { USB_RAW_SDK_IF_CLAMIN_INTERFACE_002_TEST, CheckRawSdkIfClaimInterface002},
377     { USB_RAW_SDK_IF_CLAMIN_INTERFACE_003_TEST, CheckRawSdkIfClaimInterface003},
378     { USB_RAW_SDK_IF_CLAMIN_INTERFACE_004_TEST, CheckRawSdkIfClaimInterface004},
379     { USB_RAW_SDK_IF_CLAMIN_INTERFACE_005_TEST, CheckRawSdkIfClaimInterface005},
380     { USB_RAW_SDK_IF_RELEASE_INTERFACE_001_TEST, CheckRawSdkIfReleaseInterface001},
381     { USB_RAW_SDK_IF_RELEASE_INTERFACE_002_TEST, CheckRawSdkIfReleaseInterface002},
382     { USB_RAW_SDK_IF_RELEASE_INTERFACE_003_TEST, CheckRawSdkIfReleaseInterface003},
383     { USB_RAW_SDK_IF_RELEASE_INTERFACE_004_TEST, CheckRawSdkIfReleaseInterface004},
384     { USB_RAW_SDK_IF_CLAMIN_INTERFACE_006_TEST,	 CheckRawSdkIfClaimInterface006},
385     { USB_RAW_SDK_IF_ALLOC_REQUEST_001_TEST, CheckRawSdkIfAllocRequest001},
386     { USB_RAW_SDK_IF_ALLOC_REQUEST_002_TEST, CheckRawSdkIfAllocRequest002},
387     { USB_RAW_SDK_IF_ALLOC_REQUEST_003_TEST, CheckRawSdkIfAllocRequest003},
388     { USB_RAW_SDK_IF_ALLOC_REQUEST_004_TEST, CheckRawSdkIfAllocRequest004},
389     { USB_RAW_SDK_IF_ALLOC_REQUEST_005_TEST, CheckRawSdkIfAllocRequest005},
390     { USB_RAW_SDK_IF_ALLOC_REQUEST_006_TEST, CheckRawSdkIfAllocRequest006},
391     { USB_RAW_SDK_IF_ALLOC_REQUEST_007_TEST, CheckRawSdkIfAllocRequest007},
392     { USB_RAW_SDK_IF_ALLOC_REQUEST_008_TEST, CheckRawSdkIfAllocRequest008},
393     { USB_RAW_SDK_IF_ALLOC_REQUEST_010_TEST, CheckRawSdkIfAllocRequest010},
394     { USB_RAW_SDK_IF_ALLOC_REQUEST_011_TEST, CheckRawSdkIfAllocRequest011},
395     { USB_RAW_SDK_IF_FREE_REQUEST_006_TEST, CheckRawSdkIfFreeRequest006},
396     { USB_RAW_SDK_IF_FILL_ISO_REQUEST_001_TEST, CheckRawSdkIfFillIsoRequest001},
397     { USB_RAW_SDK_IF_FILL_ISO_REQUEST_002_TEST, CheckRawSdkIfFillIsoRequest002},
398     { USB_RAW_SDK_IF_FILL_ISO_REQUEST_003_TEST, CheckRawSdkIfFillIsoRequest003},
399     { USB_RAW_SDK_IF_FILL_ISO_REQUEST_004_TEST, CheckRawSdkIfFillIsoRequest004},
400     { USB_RAW_SDK_IF_FILL_ISO_REQUEST_005_TEST, CheckRawSdkIfFillIsoRequest005},
401     { USB_RAW_SDK_IF_FILL_ISO_REQUEST_006_TEST, CheckRawSdkIfFillIsoRequest006},
402     { USB_RAW_SDK_IF_FREE_REQUEST_001_TEST, CheckRawSdkIfFreeRequest001},
403     { USB_RAW_SDK_IF_FREE_REQUEST_002_TEST, CheckRawSdkIfFreeRequest002},
404     { USB_RAW_SDK_IF_FREE_REQUEST_003_TEST, CheckRawSdkIfFreeRequest003},
405     { USB_RAW_SDK_IF_FREE_REQUEST_004_TEST, CheckRawSdkIfFreeRequest004},
406     { USB_RAW_SDK_IF_FREE_REQUEST_005_TEST, CheckRawSdkIfFreeRequest005},
407     { USB_RAW_SDK_IF_ALLOC_REQUEST_009_TEST, CheckRawSdkIfAllocRequest009},
408     { USB_RAW_SDK_IF_GET_DESCRIPTION_001_TEST, CheckRawSdkIfGetDescriptor001},
409     { USB_RAW_SDK_IF_GET_DESCRIPTION_002_TEST, CheckRawSdkIfGetDescriptor002},
410     { USB_RAW_SDK_IF_GET_DESCRIPTION_003_TEST, CheckRawSdkIfGetDescriptor003},
411     { USB_RAW_SDK_IF_GET_DESCRIPTION_004_TEST, CheckRawSdkIfGetDescriptor004},
412     { USB_RAW_SDK_IF_GET_DESCRIPTION_005_TEST, CheckRawSdkIfGetDescriptor005},
413     { USB_RAW_SDK_IF_GET_DESCRIPTION_006_TEST, CheckRawSdkIfGetDescriptor006},
414     { USB_RAW_SDK_IF_GET_DESCRIPTION_007_TEST, CheckRawSdkIfGetDescriptor007},
415     { USB_RAW_SDK_IF_GET_DESCRIPTION_008_TEST, CheckRawSdkIfGetDescriptor008},
416     { USB_RAW_SDK_IF_GET_DESCRIPTION_009_TEST, CheckRawSdkIfGetDescriptor009},
417     { USB_RAW_SDK_IF_GET_DESCRIPTION_010_TEST, CheckRawSdkIfGetDescriptor010},
418     { USB_RAW_SDK_IF_GET_DESCRIPTION_011_TEST, CheckRawSdkIfGetDescriptor011},
419     { USB_RAW_SDK_IF_GET_DESCRIPTION_012_TEST, CheckRawSdkIfGetDescriptor012},
420     { USB_RAW_SDK_IF_GET_DESCRIPTION_013_TEST, CheckRawSdkIfGetDescriptor013},
421     { USB_RAW_SDK_IF_GET_DESCRIPTION_014_TEST, CheckRawSdkIfGetDescriptor014},
422     { USB_RAW_SDK_IF_GET_DESCRIPTION_015_TEST, CheckRawSdkIfGetDescriptor015},
423     { USB_RAW_SDK_IF_GET_DESCRIPTION_016_TEST, CheckRawSdkIfGetDescriptor016},
424     { USB_RAW_SDK_IF_FILL_BULK_REQUEST_001_TEST, CheckRawSdkIfFillBulkRequest001},
425     { USB_RAW_SDK_IF_FILL_BULK_REQUEST_002_TEST, CheckRawSdkIfFillBulkRequest002},
426     { USB_RAW_SDK_IF_FILL_INT_REQUEST_001_TEST, CheckRawSdkIfFillInterruptRequest001},
427     { USB_RAW_SDK_IF_FILL_INT_REQUEST_002_TEST, CheckRawSdkIfFillInterruptRequest002},
428     { USB_RAW_SDK_IF_FILL_INT_REQUEST_003_TEST, CheckRawSdkIfFillInterruptRequest003},
429     { USB_RAW_SDK_IF_FILL_INT_REQUEST_004_TEST, CheckRawSdkIfFillInterruptRequest004},
430     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_001_TEST, CheckRawSdkIfFillControlRequest001},
431     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_002_TEST, CheckRawSdkIfFillControlRequest002},
432     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_003_TEST, CheckRawSdkIfFillControlRequest003},
433     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_004_TEST, CheckRawSdkIfFillControlRequest004},
434     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_005_TEST, CheckRawSdkIfFillControlRequest005},
435     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_006_TEST, CheckRawSdkIfFillControlRequest006},
436     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_007_TEST, CheckRawSdkIfFillControlRequest007},
437     { USB_RAW_SDK_IF_FILL_CONTROL_REQUEST_008_TEST, CheckRawSdkIfFillControlRequest008},
438     { USB_RAW_SDK_IF_FILL_CONTROL_SETUP_001_TEST, CheckRawSdkIfFillControlSetup001},
439     { USB_RAW_SDK_IF_FILL_CONTROL_SETUP_002_TEST, CheckRawSdkIfFillControlSetup002},
440     { USB_RAW_SDK_IF_FILL_CONTROL_SETUP_003_TEST, CheckRawSdkIfFillControlSetup003},
441     { USB_RAW_SDK_IF_FILL_CONTROL_SETUP_004_TEST, CheckRawSdkIfFillControlSetup004},
442     { USB_RAW_SDK_IF_SEND_CONTROL_REQUEST_001_TEST, CheckRawSdkIfSendControlRequest001},
443     { USB_RAW_SDK_IF_SEND_CONTROL_REQUEST_002_TEST, CheckRawSdkIfSendControlRequest002},
444     { USB_RAW_SDK_IF_SEND_CONTROL_REQUEST_003_TEST, CheckRawSdkIfSendControlRequest003},
445     { USB_RAW_SDK_IF_SEND_CONTROL_REQUEST_004_TEST, CheckRawSdkIfSendControlRequest004},
446     { USB_RAW_SDK_IF_SEND_CONTROL_REQUEST_005_TEST, CheckRawSdkIfSendControlRequest005},
447     { USB_RAW_SDK_IF_SEND_CONTROL_REQUEST_006_TEST, CheckRawSdkIfSendControlRequest006},
448     { USB_RAW_SDK_IF_SEND_CONTROL_REQUEST_007_TEST, CheckRawSdkIfSendControlRequest007},
449     { USB_RAW_SDK_IF_SEND_BULK_REQUEST_001_TEST, CheckRawSdkIfSendBulkRequest001},
450     { USB_RAW_SDK_IF_SEND_BULK_REQUEST_002_TEST, CheckRawSdkIfSendBulkRequest002},
451     { USB_RAW_SDK_IF_SEND_BULK_REQUEST_003_TEST, CheckRawSdkIfSendBulkRequest003},
452     { USB_RAW_SDK_IF_SEND_BULK_REQUEST_004_TEST, CheckRawSdkIfSendBulkRequest004},
453     { USB_RAW_SDK_IF_SEND_BULK_REQUEST_005_TEST, CheckRawSdkIfSendBulkRequest005},
454     { USB_RAW_SDK_IF_SEND_INT_REQUEST_001_TEST, CheckRawSdkIfSendInterruptRequest001},
455     { USB_RAW_SDK_IF_SEND_INT_REQUEST_002_TEST, CheckRawSdkIfSendInterruptRequest002},
456     { USB_RAW_SDK_IF_SEND_INT_REQUEST_003_TEST, CheckRawSdkIfSendInterruptRequest003},
457     { USB_RAW_SDK_IF_SEND_INT_REQUEST_004_TEST, CheckRawSdkIfSendInterruptRequest004},
458     { USB_RAW_SDK_IF_FILL_BULK_REQUEST_003_TEST, CheckRawSdkIfFillBulkRequest003},
459     { USB_RAW_SDK_IF_FILL_BULK_REQUEST_004_TEST, CheckRawSdkIfFillBulkRequest004},
460     { USB_RAW_SDK_IF_FILL_INT_REQUEST_005_TEST, CheckRawSdkIfFillInterruptRequest005},
461     { USB_RAW_SDK_IF_SUBMIT_REQUEST_001_TEST, CheckRawSdkIfSubmitRequest001},
462     { USB_RAW_SDK_IF_SUBMIT_REQUEST_002_TEST, CheckRawSdkIfSubmitRequest002},
463     { USB_RAW_SDK_IF_SUBMIT_REQUEST_003_TEST, CheckRawSdkIfSubmitRequest003},
464     { USB_RAW_SDK_IF_SUBMIT_REQUEST_004_TEST, CheckRawSdkIfSubmitRequest004},
465     { USB_RAW_SDK_IF_CANCEL_REQUEST_001_TEST, CheckRawSdkIfCancelRequest001},
466     { USB_RAW_SDK_IF_CANCEL_REQUEST_002_TEST, CheckRawSdkIfCancelRequest002},
467     { USB_RAW_SDK_IF_CANCEL_REQUEST_003_TEST, CheckRawSdkIfCancelRequest003},
468     { USB_RAW_SDK_IF_CANCEL_REQUEST_004_TEST, CheckRawSdkIfCancelRequest004},
469     { USB_RAW_SDK_IF_STOP_IO, UsbStopIo},
470 
471 };
472 
UsbRawTestEntry(int32_t cmd)473 int32_t UsbRawTestEntry(int32_t cmd)
474 {
475     int32_t i;
476     int32_t ret = HDF_ERR_NOT_SUPPORT;
477 
478     if (g_initFlag == false) {
479 #ifdef LOSCFG_DRIVERS_HDF_USB_PNP_NOTIFY
480         struct UsbGetDevicePara paraData;
481         struct usb_device *usbPnpDevice = NULL;
482         paraData.type = USB_PNP_DEVICE_VENDOR_PRODUCT_TYPE;
483         paraData.vendorId = USB_DEVICE_VENDOR_ID;
484         paraData.productId = USB_DEVICE_PRODUCT_ID;
485         usbPnpDevice = UsbPnpNotifyGetUsbDevice(paraData);
486         if (usbPnpDevice == NULL) {
487             HDF_LOGE("%s:%d UsbPnpNotifyGetUsbDevice is NULL!", __func__, __LINE__);
488             return HDF_ERR_INVALID_PARAM;
489         }
490         g_acm->busNum = usbPnpDevice->address;
491         g_acm->devAddr = usbPnpDevice->port_no;
492         HDF_LOGE("%s: busNum %d++devAddr %d", __func__, g_acm->busNum, g_acm->devAddr);
493         g_initFlag = true;
494 #else
495         HDF_LOGE("%s:%d pnp notify module is not support!", __func__, __LINE__);
496         return HDF_ERR_NOT_SUPPORT;
497 #endif
498     }
499     for (i = 0; i < sizeof(g_usbRawFunc) / sizeof(g_usbRawFunc[0]); i++) {
500         if (cmd == g_usbRawFunc[i].type && g_usbRawFunc[i].Func != NULL) {
501             ret = g_usbRawFunc[i].Func();
502             HDF_LOGE("%s: cmd %d ret %d", __func__, cmd, ret);
503             break;
504         }
505     }
506     return ret;
507 }
508 
CheckRawSdkIfInit001(void)509 int32_t CheckRawSdkIfInit001(void)
510 {
511     int32_t ret;
512 
513     ret = UsbRawInit(&g_session);
514     if (ret) {
515         HDF_LOGE("%s: error", __func__);
516         return HDF_FAILURE;
517     }
518     g_acm->session = g_session;
519     HDF_LOGE("%s: success", __func__);
520     return HDF_SUCCESS;
521 }
522 
CheckRawSdkIfExit001(void)523 int32_t CheckRawSdkIfExit001(void)
524 {
525     int32_t ret;
526 
527     ret = UsbRawExit(g_acm->session);
528     if (ret) {
529         HDF_LOGE("%s: error", __func__);
530         return HDF_FAILURE;
531     }
532     g_session = NULL;
533     g_acm->session = g_session;
534     HDF_LOGE("%s: success", __func__);
535     return HDF_SUCCESS;
536 }
537 
CheckRawSdkIfInit002(void)538 int32_t CheckRawSdkIfInit002(void)
539 {
540     int32_t ret;
541 
542     ret = UsbRawInit(NULL);
543     if (ret) {
544         HDF_LOGE("%s: error", __func__);
545         return HDF_FAILURE;
546     }
547     HDF_LOGE("%s: success", __func__);
548     return HDF_SUCCESS;
549 }
550 
CheckRawSdkIfExit002(void)551 int32_t CheckRawSdkIfExit002(void)
552 {
553     int32_t ret = UsbRawExit(NULL);
554     if (ret != HDF_SUCCESS) {
555         HDF_LOGE("%s: error", __func__);
556         return HDF_FAILURE;
557     }
558     HDF_LOGE("%s: success", __func__);
559     return HDF_SUCCESS;
560 }
561 
CheckRawSdkIfInit003(void)562 int32_t CheckRawSdkIfInit003(void)
563 {
564     for (int32_t i = 0; i < USB_LOOP_NUM; i++) {
565         int32_t ret = UsbRawInit(&g_session);
566         if (ret != HDF_SUCCESS) {
567             HDF_LOGE("%s: error", __func__);
568             return HDF_FAILURE;
569         }
570         g_acm->session = g_session;
571         ret = UsbRawExit(g_acm->session);
572         if (ret != HDF_SUCCESS) {
573             HDF_LOGE("%s: error", __func__);
574             return HDF_FAILURE;
575         }
576         g_session = NULL;
577         g_acm->session = g_session;
578     }
579     HDF_LOGE("%s: success", __func__);
580     return HDF_SUCCESS;
581 }
582 
CheckRawSdkIfInit004(void)583 int32_t CheckRawSdkIfInit004(void)
584 {
585     for (int32_t i = 0; i < USB_LOOP_NUM; i++) {
586         int32_t ret = UsbRawInit(NULL);
587         if (ret != HDF_SUCCESS) {
588             HDF_LOGE("%s: error", __func__);
589             return HDF_FAILURE;
590         }
591         ret = UsbRawExit(NULL);
592         if (ret != HDF_SUCCESS) {
593             HDF_LOGE("%s: error", __func__);
594             return HDF_FAILURE;
595         }
596     }
597     HDF_LOGE("%s: success", __func__);
598     return HDF_SUCCESS;
599 }
600 
CheckRawSdkIfInit005(void)601 int32_t CheckRawSdkIfInit005(void)
602 {
603     int32_t ret = UsbRawInit(&g_session);
604     if (ret != HDF_SUCCESS) {
605         HDF_LOGE("%s: error", __func__);
606         return HDF_FAILURE;
607     }
608     g_acm->session = g_session;
609     HDF_LOGE("%s: success", __func__);
610     return HDF_SUCCESS;
611 }
612 
CheckRawSdkIfOpenDevice001(void)613 int32_t CheckRawSdkIfOpenDevice001(void)
614 {
615     g_devHandle = UsbRawOpenDevice(NULL, g_acm->busNum, g_acm->devAddr);
616     if (g_devHandle) {
617         HDF_LOGE("%s: error", __func__);
618         return HDF_FAILURE;
619     }
620     g_acm->devHandle = g_devHandle;
621     HDF_LOGE("%s: success", __func__);
622     return HDF_SUCCESS;
623 }
624 
CheckRawSdkIfOpenDevice002(void)625 int32_t CheckRawSdkIfOpenDevice002(void)
626 {
627     uint8_t busNum = 1U;
628     uint8_t devAddr = 100U;
629     g_devHandle = UsbRawOpenDevice(g_acm->session, busNum, devAddr);
630     if (g_devHandle) {
631         HDF_LOGE("%s: error", __func__);
632         return HDF_FAILURE;
633     }
634     g_acm->devHandle = g_devHandle;
635     HDF_LOGE("%s: success", __func__);
636     return HDF_SUCCESS;
637 }
638 
CheckRawSdkIfOpenDevice003(void)639 int32_t CheckRawSdkIfOpenDevice003(void)
640 {
641     uint8_t busNum = 1U;
642     uint8_t devAddr = 255U;
643     g_devHandle = UsbRawOpenDevice(g_acm->session, busNum, devAddr);
644     if (g_devHandle) {
645         HDF_LOGE("%s: error", __func__);
646         return HDF_FAILURE;
647     }
648     g_acm->devHandle = g_devHandle;
649     HDF_LOGE("%s: success", __func__);
650     return HDF_SUCCESS;
651 }
652 
CheckRawSdkIfOpenDevice004(void)653 int32_t CheckRawSdkIfOpenDevice004(void)
654 {
655     uint8_t busNum = 100U;
656     uint8_t devAddr = 2U;
657     g_devHandle = UsbRawOpenDevice(g_acm->session, busNum, devAddr);
658     if (g_devHandle) {
659         HDF_LOGE("%s: error", __func__);
660         return HDF_FAILURE;
661     }
662     g_acm->devHandle = g_devHandle;
663     HDF_LOGE("%s: success", __func__);
664     return HDF_SUCCESS;
665 }
666 
CheckRawSdkIfOpenDevice005(void)667 int32_t CheckRawSdkIfOpenDevice005(void)
668 {
669     uint8_t busNum = 255U;
670     uint8_t devAddr = 2U;
671     g_devHandle = UsbRawOpenDevice(g_acm->session, busNum, devAddr);
672     if (g_devHandle) {
673         HDF_LOGE("%s: error", __func__);
674         return HDF_FAILURE;
675     }
676     g_acm->devHandle = g_devHandle;
677     HDF_LOGE("%s: success", __func__);
678     return HDF_SUCCESS;
679 }
680 
CheckRawSdkIfOpenDevice006(void)681 int32_t CheckRawSdkIfOpenDevice006(void)
682 {
683     g_devHandle = UsbRawOpenDevice(g_acm->session, g_acm->busNum, g_acm->devAddr);
684     if (g_devHandle == NULL) {
685         HDF_LOGE("%s: error", __func__);
686         return HDF_FAILURE;
687     }
688     g_acm->devHandle = g_devHandle;
689     HDF_LOGE("%s: success", __func__);
690     return HDF_SUCCESS;
691 }
692 
CheckRawSdkIfResetDevice001(void)693 int32_t CheckRawSdkIfResetDevice001(void)
694 {
695     int32_t ret;
696 
697     ret = UsbRawResetDevice(NULL);
698     if (ret != HDF_ERR_INVALID_PARAM) {
699         HDF_LOGE("%s: error", __func__);
700         return HDF_FAILURE;
701     }
702     HDF_LOGE("%s: success", __func__);
703     return HDF_SUCCESS;
704 }
705 
CheckRawSdkIfResetDevice002(void)706 int32_t CheckRawSdkIfResetDevice002(void)
707 {
708     int32_t ret;
709 
710     ret = UsbRawResetDevice(g_acm->devHandle);
711     if (ret) {
712         HDF_LOGE("%s: error", __func__);
713         return HDF_FAILURE;
714     }
715     HDF_LOGE("%s: success", __func__);
716     return HDF_SUCCESS;
717 }
718 
CheckRawSdkIfCloseDevice001(void)719 int32_t CheckRawSdkIfCloseDevice001(void)
720 {
721     int32_t ret;
722 
723     ret = UsbRawCloseDevice(NULL);
724     if (ret != HDF_ERR_INVALID_PARAM) {
725         HDF_LOGE("%s: error", __func__);
726         return HDF_FAILURE;
727     }
728     HDF_LOGE("%s: success", __func__);
729     return HDF_SUCCESS;
730 }
731 
CheckRawSdkIfCloseDevice002(void)732 int32_t CheckRawSdkIfCloseDevice002(void)
733 {
734     int32_t ret;
735 
736     ret = UsbRawCloseDevice(g_acm->devHandle);
737     if (ret) {
738         HDF_LOGE("%s: error", __func__);
739         return HDF_FAILURE;
740     }
741     g_acm->devHandle = NULL;
742     g_devHandle = g_acm->devHandle;
743     HDF_LOGE("%s: success", __func__);
744     return HDF_SUCCESS;
745 }
746 
CheckRawSdkIfOpenDevice007(void)747 int32_t CheckRawSdkIfOpenDevice007(void)
748 {
749     g_devHandle = UsbRawOpenDevice(g_session, g_acm->busNum, g_acm->devAddr);
750     if (g_devHandle == NULL) {
751         HDF_LOGE("%s: error", __func__);
752         return HDF_FAILURE;
753     }
754     g_acm->devHandle = g_devHandle;
755     HDF_LOGE("%s: success", __func__);
756     return HDF_SUCCESS;
757 }
758 
CheckRawSdkIfGetConfiguration001(void)759 int32_t CheckRawSdkIfGetConfiguration001(void)
760 {
761     int32_t ret;
762 
763     ret = UsbRawGetConfiguration(NULL, &g_activeConfig);
764     if (ret != HDF_ERR_INVALID_PARAM) {
765         HDF_LOGE("%s: error", __func__);
766         return HDF_FAILURE;
767     }
768     HDF_LOGE("%s: success", __func__);
769     return HDF_SUCCESS;
770 }
771 
CheckRawSdkIfGetConfiguration002(void)772 int32_t CheckRawSdkIfGetConfiguration002(void)
773 {
774     int32_t ret;
775 
776     ret = UsbRawGetConfiguration(g_acm->devHandle, NULL);
777     if (ret != HDF_ERR_INVALID_PARAM) {
778         HDF_LOGE("%s: error", __func__);
779         return HDF_FAILURE;
780     }
781     HDF_LOGE("%s: success", __func__);
782     return HDF_SUCCESS;
783 }
784 
CheckRawSdkIfGetConfiguration003(void)785 int32_t CheckRawSdkIfGetConfiguration003(void)
786 {
787     int32_t ret;
788 
789     ret = UsbRawGetConfiguration(NULL, NULL);
790     if (ret != HDF_ERR_INVALID_PARAM) {
791         HDF_LOGE("%s: error", __func__);
792         return HDF_FAILURE;
793     }
794     HDF_LOGE("%s: success", __func__);
795     return HDF_SUCCESS;
796 }
797 
CheckRawSdkIfGetConfiguration004(void)798 int32_t CheckRawSdkIfGetConfiguration004(void)
799 {
800     int32_t ret;
801 
802     ret = UsbRawGetConfiguration(g_acm->devHandle, &g_activeConfig);
803     printf("------g_activeConfig = [%d]------\n", g_activeConfig);
804     if (ret) {
805         HDF_LOGE("%s: error", __func__);
806         return HDF_FAILURE;
807     }
808     HDF_LOGE("%s: success", __func__);
809     return HDF_SUCCESS;
810 }
811 
CheckRawSdkIfGetDevice001(void)812 int32_t CheckRawSdkIfGetDevice001(void)
813 {
814     g_dev = UsbRawGetDevice(NULL);
815     if (g_dev) {
816         HDF_LOGE("%s: error", __func__);
817         return HDF_FAILURE;
818     }
819     HDF_LOGE("%s: success", __func__);
820     return HDF_SUCCESS;
821 }
822 
CheckRawSdkIfGetDevice002(void)823 int32_t CheckRawSdkIfGetDevice002(void)
824 {
825     g_dev = UsbRawGetDevice(g_acm->devHandle);
826     if (g_dev == NULL) {
827         HDF_LOGE("%s: error", __func__);
828         return HDF_FAILURE;
829     }
830     HDF_LOGE("%s: success", __func__);
831     return HDF_SUCCESS;
832 }
833 
834 
CheckRawSdkIfClaimInterface002(void)835 int32_t CheckRawSdkIfClaimInterface002(void)
836 {
837     int32_t ret;
838     int32_t interfaceNumber = 1;
839 
840     ret = UsbRawClaimInterface(g_devHandle, interfaceNumber);
841     if (ret) {
842         HDF_LOGE("%s: error", __func__);
843         return HDF_FAILURE;
844     }
845     HDF_LOGE("%s: success", __func__);
846     return HDF_SUCCESS;
847 }
848 
CheckRawSdkIfClaimInterface003(void)849 int32_t CheckRawSdkIfClaimInterface003(void)
850 {
851     int32_t ret;
852     int32_t interfaceNumber = 0;
853 
854     ret = UsbRawClaimInterface(g_devHandle, interfaceNumber);
855     if (ret) {
856         HDF_LOGE("%s: error", __func__);
857         return HDF_FAILURE;
858     }
859     HDF_LOGE("%s: success", __func__);
860     return HDF_SUCCESS;
861 }
862 
CheckRawSdkIfClaimInterface004(void)863 int32_t CheckRawSdkIfClaimInterface004(void)
864 {
865     int32_t ret;
866     int32_t interfaceNumber = USB_MAX_BYTE;
867 
868     ret = UsbRawClaimInterface(g_devHandle, interfaceNumber);
869     if (ret != HDF_ERR_INVALID_PARAM) {
870         HDF_LOGE("%s: error", __func__);
871         return HDF_FAILURE;
872     }
873     HDF_LOGE("%s: success", __func__);
874     return HDF_SUCCESS;
875 }
876 
CheckRawSdkIfGetDeviceDescriptor002(void)877 int32_t CheckRawSdkIfGetDeviceDescriptor002(void)
878 {
879     int32_t ret;
880 
881     ret = UsbRawGetDeviceDescriptor(g_dev, NULL);
882     if (ret != HDF_ERR_INVALID_PARAM) {
883         HDF_LOGE("%s: error", __func__);
884         return HDF_FAILURE;
885     }
886     HDF_LOGE("%s: success", __func__);
887     return HDF_SUCCESS;
888 }
889 
CheckRawSdkIfGetDeviceDescriptor003(void)890 int32_t CheckRawSdkIfGetDeviceDescriptor003(void)
891 {
892     int32_t ret;
893 
894     ret = UsbRawGetDeviceDescriptor(NULL, NULL);
895     if (ret != HDF_ERR_INVALID_PARAM) {
896         HDF_LOGE("%s: error", __func__);
897         return HDF_FAILURE;
898     }
899     HDF_LOGE("%s: success", __func__);
900     return HDF_SUCCESS;
901 }
902 
CheckRawSdkIfGetDeviceDescriptor004(void)903 int32_t CheckRawSdkIfGetDeviceDescriptor004(void)
904 {
905     struct UsbDeviceDescriptor desc;
906     int32_t ret;
907 
908     ret = UsbRawGetDeviceDescriptor(g_dev, &desc);
909     if (ret) {
910         HDF_LOGE("%s: error", __func__);
911         return HDF_FAILURE;
912     }
913     HDF_LOGE("%s: success", __func__);
914     return HDF_SUCCESS;
915 }
916 
CheckRawSdkIfGetConfigDescriptor005(void)917 int32_t CheckRawSdkIfGetConfigDescriptor005(void)
918 {
919     int32_t ret;
920 
921     printf("------g_activeConfig = [%d]------\n", g_activeConfig);
922     ret = UsbRawGetConfigDescriptor(g_dev, g_activeConfig, &g_acm->config);
923     if (ret) {
924         HDF_LOGE("%s: error", __func__);
925         return HDF_FAILURE;
926     }
927     HDF_LOGE("%s: success", __func__);
928     return HDF_SUCCESS;
929 }
930 
CheckRawSdkIfGetDeviceDescriptor005(void)931 int32_t CheckRawSdkIfGetDeviceDescriptor005(void)
932 {
933     struct UsbDeviceDescriptor desc;
934     int32_t ret;
935 
936     ret = UsbRawGetDeviceDescriptor(g_dev, &desc);
937     if (ret) {
938         HDF_LOGE("%s: error", __func__);
939         return HDF_FAILURE;
940     }
941     HDF_LOGE("%s: success", __func__);
942     return HDF_SUCCESS;
943 }
944 
CheckRawSdkIfGetConfigDescriptor001(void)945 int32_t CheckRawSdkIfGetConfigDescriptor001(void)
946 {
947     int32_t ret;
948 
949     ret = UsbRawGetConfigDescriptor(NULL, g_activeConfig, &g_acm->config);
950     if (ret != HDF_ERR_INVALID_PARAM) {
951         HDF_LOGE("%s: error", __func__);
952         return HDF_FAILURE;
953     }
954     HDF_LOGE("%s: success", __func__);
955     return HDF_SUCCESS;
956 }
957 
CheckRawSdkIfGetConfigDescriptor002(void)958 int32_t CheckRawSdkIfGetConfigDescriptor002(void)
959 {
960     int32_t ret;
961 
962     ret = UsbRawGetConfigDescriptor(g_dev, g_activeConfig, NULL);
963     if (ret != HDF_ERR_INVALID_PARAM) {
964         HDF_LOGE("%s: error", __func__);
965         return HDF_FAILURE;
966     }
967     HDF_LOGE("%s: success", __func__);
968     return HDF_SUCCESS;
969 }
970 
CheckRawSdkIfGetConfigDescriptor003(void)971 int32_t CheckRawSdkIfGetConfigDescriptor003(void)
972 {
973     int32_t ret;
974 
975     ret = UsbRawGetConfigDescriptor(NULL, g_activeConfig, NULL);
976     if (ret != HDF_ERR_INVALID_PARAM) {
977         HDF_LOGE("%s: error", __func__);
978         return HDF_FAILURE;
979     }
980     HDF_LOGE("%s: success", __func__);
981     return HDF_SUCCESS;
982 }
983 
CheckRawSdkIfGetConfigDescriptor004(void)984 int32_t CheckRawSdkIfGetConfigDescriptor004(void)
985 {
986     int32_t ret;
987 
988     printf("------g_activeConfig = [%d]------\n", g_activeConfig);
989     ret = UsbRawGetConfigDescriptor(g_dev, g_activeConfig, &g_acm->config);
990     if (ret) {
991         HDF_LOGE("%s: error", __func__);
992         return HDF_FAILURE;
993     }
994     HDF_LOGE("%s: success", __func__);
995     return HDF_SUCCESS;
996 }
997 
CheckRawSdkIfSetConfiguration001(void)998 int32_t CheckRawSdkIfSetConfiguration001(void)
999 {
1000     int32_t ret;
1001     int32_t config = 0;
1002 
1003     ret = UsbRawSetConfiguration(NULL, config);
1004     if (ret != HDF_ERR_INVALID_PARAM) {
1005         HDF_LOGE("%s: error", __func__);
1006         return HDF_FAILURE;
1007     }
1008     HDF_LOGE("%s: success", __func__);
1009     return HDF_SUCCESS;
1010 }
1011 
CheckRawSdkIfSetConfiguration002(void)1012 int32_t CheckRawSdkIfSetConfiguration002(void)
1013 {
1014     int32_t ret;
1015     int32_t config = 0;
1016 
1017     ret = UsbRawSetConfiguration(g_acm->devHandle, config);
1018     if (ret) {
1019         HDF_LOGE("%s: error", __func__);
1020         return HDF_FAILURE;
1021     }
1022     HDF_LOGE("%s: success", __func__);
1023     return HDF_SUCCESS;
1024 }
1025 
CheckRawSdkIfSetConfiguration003(void)1026 int32_t CheckRawSdkIfSetConfiguration003(void)
1027 {
1028     int32_t ret;
1029     int32_t config = 1;
1030 
1031     ret = UsbRawSetConfiguration(g_acm->devHandle, config);
1032     if (ret) {
1033         HDF_LOGE("%s: error", __func__);
1034         return HDF_FAILURE;
1035     }
1036     HDF_LOGE("%s: success", __func__);
1037     return HDF_SUCCESS;
1038 }
1039 
CheckRawSdkIfSetConfiguration004(void)1040 int32_t CheckRawSdkIfSetConfiguration004(void)
1041 {
1042     int32_t ret;
1043     int32_t config = 10;
1044 
1045     ret = UsbRawSetConfiguration(g_acm->devHandle, config);
1046     if (ret != HDF_SUCCESS) {
1047         HDF_LOGE("%s: error", __func__);
1048         return HDF_SUCCESS;
1049     }
1050     HDF_LOGE("%s: success", __func__);
1051     return HDF_FAILURE;
1052 }
1053 
CheckRawSdkIfSetConfiguration005(void)1054 int32_t CheckRawSdkIfSetConfiguration005(void)
1055 {
1056     int32_t ret;
1057     int32_t config = 100;
1058 
1059     ret = UsbRawSetConfiguration(g_acm->devHandle, config);
1060     if (ret != HDF_SUCCESS) {
1061         HDF_LOGE("%s: error", __func__);
1062         return HDF_SUCCESS;
1063     }
1064     HDF_LOGE("%s: success", __func__);
1065     return HDF_FAILURE;
1066 }
1067 
CheckRawSdkIfSetConfiguration006(void)1068 int32_t CheckRawSdkIfSetConfiguration006(void)
1069 {
1070     int32_t ret;
1071     int32_t config = 200;
1072 
1073     ret = UsbRawSetConfiguration(g_acm->devHandle, config);
1074     if (ret != HDF_SUCCESS) {
1075         HDF_LOGE("%s: error", __func__);
1076         return HDF_SUCCESS;
1077     }
1078     HDF_LOGE("%s: success", __func__);
1079     return HDF_FAILURE;
1080 }
1081 
CheckRawSdkIfSetConfiguration007(void)1082 int32_t CheckRawSdkIfSetConfiguration007(void)
1083 {
1084     int32_t ret;
1085     int32_t config = USB_MAX_BYTE;
1086 
1087     ret = UsbRawSetConfiguration(g_acm->devHandle, config);
1088     if (ret != HDF_SUCCESS) {
1089         HDF_LOGE("%s: error", __func__);
1090         return HDF_SUCCESS;
1091     }
1092     HDF_LOGE("%s: success", __func__);
1093     return HDF_FAILURE;
1094 }
1095 
CheckRawSdkIfSetConfiguration008(void)1096 int32_t CheckRawSdkIfSetConfiguration008(void)
1097 {
1098     int32_t ret;
1099     int32_t config = 0;
1100 
1101     ret = UsbRawSetConfiguration(g_acm->devHandle, config);
1102     if (ret) {
1103         HDF_LOGE("%s: error", __func__);
1104         return HDF_FAILURE;
1105     }
1106     HDF_LOGE("%s: success", __func__);
1107     return HDF_SUCCESS;
1108 }
1109