• 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 #define HDF_LOG_TAG usb_raw_test_c
24 
CheckRawSdkIfGetDeviceDescriptor001(void)25 int32_t CheckRawSdkIfGetDeviceDescriptor001(void)
26 {
27     struct UsbDeviceDescriptor desc;
28     int32_t ret;
29     ret = UsbRawGetDeviceDescriptor(NULL, &desc);
30     if (ret != HDF_ERR_INVALID_PARAM) {
31         HDF_LOGE("%s: error", __func__);
32         return HDF_FAILURE;
33     }
34     HDF_LOGE("%s: success", __func__);
35     return HDF_SUCCESS;
36 }
37 
CheckRawSdkIfClaimInterface001(void)38 int32_t CheckRawSdkIfClaimInterface001(void)
39 {
40     int32_t ret;
41     int32_t interfaceNumber = 1;
42 
43     ret = UsbRawClaimInterface(NULL, interfaceNumber);
44     if (ret != HDF_ERR_INVALID_PARAM) {
45         HDF_LOGE("%s: error", __func__);
46         return HDF_FAILURE;
47     }
48     HDF_LOGE("%s: success", __func__);
49     return HDF_SUCCESS;
50 }
51 
CheckRawSdkIfClaimInterface005(void)52 int32_t CheckRawSdkIfClaimInterface005(void)
53 {
54     int32_t ret;
55     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
56 
57     ret = UsbParseConfigDescriptor(rawAcm, rawAcm->config);
58     if (ret) {
59         HDF_LOGE("%s: error", __func__);
60         return HDF_FAILURE;
61     }
62     HDF_LOGE("%s: success", __func__);
63     return HDF_SUCCESS;
64 }
65 
CheckRawSdkIfReleaseInterface001(void)66 int32_t CheckRawSdkIfReleaseInterface001(void)
67 {
68     int32_t ret;
69     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
70 
71     ret = UsbRawReleaseInterface(NULL, rawAcm->ctrlIface);
72     if (ret != HDF_ERR_INVALID_PARAM) {
73         HDF_LOGE("%s: error", __func__);
74         return HDF_FAILURE;
75     }
76     HDF_LOGE("%s: success", __func__);
77     return HDF_SUCCESS;
78 }
79 
CheckRawSdkIfReleaseInterface002(void)80 int32_t CheckRawSdkIfReleaseInterface002(void)
81 {
82     int32_t ret;
83     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
84 
85     ret = UsbRawReleaseInterface(rawAcm->devHandle, rawAcm->ctrlIface);
86     if (ret) {
87         HDF_LOGE("%s: error", __func__);
88         return HDF_FAILURE;
89     }
90     HDF_LOGE("%s: success", __func__);
91     return HDF_SUCCESS;
92 }
93 
CheckRawSdkIfReleaseInterface003(void)94 int32_t CheckRawSdkIfReleaseInterface003(void)
95 {
96     int32_t ret;
97     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
98 
99     ret = UsbRawReleaseInterface(NULL, rawAcm->dataIface);
100     if (ret != HDF_ERR_INVALID_PARAM) {
101         HDF_LOGE("%s: error", __func__);
102         return HDF_FAILURE;
103     }
104     HDF_LOGE("%s: success", __func__);
105     return HDF_SUCCESS;
106 }
107 
CheckRawSdkIfReleaseInterface004(void)108 int32_t CheckRawSdkIfReleaseInterface004(void)
109 {
110     int32_t ret;
111     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
112 
113     ret = UsbRawReleaseInterface(rawAcm->devHandle, rawAcm->dataIface);
114     if (ret) {
115         HDF_LOGE("%s: error", __func__);
116         return HDF_FAILURE;
117     }
118     HDF_LOGE("%s: success", __func__);
119     return HDF_SUCCESS;
120 }
121 
CheckRawSdkIfClaimInterface006(void)122 int32_t CheckRawSdkIfClaimInterface006(void)
123 {
124     int32_t ret;
125     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
126 
127     ret = UsbParseConfigDescriptor(rawAcm, rawAcm->config);
128     if (ret) {
129         HDF_LOGE("%s: error", __func__);
130         return HDF_FAILURE;
131     }
132     HDF_LOGE("%s: success", __func__);
133     return HDF_SUCCESS;
134 }
135 
CheckRawSdkIfAllocRequest001(void)136 int32_t CheckRawSdkIfAllocRequest001(void)
137 {
138     int32_t i;
139     int32_t ret;
140     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
141 
142     ret = AcmWriteBufAlloc(rawAcm);
143     if (ret) {
144         HDF_LOGE("%s: error", __func__);
145         return HDF_FAILURE;
146     }
147 
148     for (i = 0; i < ACM_NW; i++) {
149         rawAcm->wb[i].request = UsbRawAllocRequest(NULL, 0, rawAcm->dataOutEp.maxPacketSize);
150         rawAcm->wb[i].instance = rawAcm;
151         if (rawAcm->wb[i].request) {
152             HDF_LOGE("%s: error", __func__);
153             return HDF_FAILURE;
154         }
155     }
156     HDF_LOGE("%s: success", __func__);
157     return HDF_SUCCESS;
158 }
159 
CheckRawSdkIfAllocRequest002(void)160 int32_t CheckRawSdkIfAllocRequest002(void)
161 {
162     int32_t i;
163     int32_t ret;
164     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
165 
166     ret = AcmWriteBufAlloc(rawAcm);
167     if (ret) {
168         HDF_LOGE("%s: error", __func__);
169         return HDF_FAILURE;
170     }
171 
172     for (i = 0; i < ACM_NW; i++) {
173         rawAcm->wb[i].request = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->dataOutEp.maxPacketSize);
174         rawAcm->wb[i].instance = rawAcm;
175         if (rawAcm->wb[i].request == NULL) {
176             HDF_LOGE("%s: error", __func__);
177             return HDF_FAILURE;
178         }
179         ((struct UsbHostRequest *)(rawAcm->wb[i].request))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
180     }
181     HDF_LOGE("%s: success", __func__);
182     return HDF_SUCCESS;
183 }
184 
CheckRawSdkIfAllocRequest003(void)185 int32_t CheckRawSdkIfAllocRequest003(void)
186 {
187     int32_t i;
188     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
189 
190     for (i = 0; i < ACM_NR; i++) {
191         rawAcm->readReq[i] = UsbRawAllocRequest(NULL, 0, rawAcm->dataInEp.maxPacketSize);
192         if (rawAcm->readReq[i]) {
193             HDF_LOGE("%s: error", __func__);
194             return HDF_FAILURE;
195         }
196     }
197     HDF_LOGE("%s: success", __func__);
198     return HDF_SUCCESS;
199 }
200 
CheckRawSdkIfAllocRequest004(void)201 int32_t CheckRawSdkIfAllocRequest004(void)
202 {
203     int32_t i;
204     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
205 
206     for (i = 0; i < ACM_NR; i++) {
207         rawAcm->readReq[i] = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->dataInEp.maxPacketSize);
208         if (rawAcm->readReq[i] == NULL) {
209             HDF_LOGE("%s: error", __func__);
210             return HDF_FAILURE;
211         }
212         ((struct UsbHostRequest *)(rawAcm->readReq[i]))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
213     }
214     HDF_LOGE("%s: success", __func__);
215     return HDF_SUCCESS;
216 }
217 
CheckRawSdkIfAllocRequest005(void)218 int32_t CheckRawSdkIfAllocRequest005(void)
219 {
220     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
221     rawAcm->ctrlReq = UsbRawAllocRequest(NULL, 0, USB_CTRL_REQ_SIZE);
222     if (rawAcm->ctrlReq) {
223         HDF_LOGE("%s: error", __func__);
224         return HDF_FAILURE;
225     }
226     HDF_LOGE("%s: success", __func__);
227     return HDF_SUCCESS;
228 }
229 
CheckRawSdkIfAllocRequest006(void)230 int32_t CheckRawSdkIfAllocRequest006(void)
231 {
232     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
233     rawAcm->ctrlReq = UsbRawAllocRequest(rawAcm->devHandle, 0, USB_CTRL_REQ_SIZE);
234     if (rawAcm->ctrlReq == NULL) {
235         HDF_LOGE("%s: error", __func__);
236         return HDF_FAILURE;
237     }
238     ((struct UsbHostRequest *)(rawAcm->ctrlReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
239     HDF_LOGE("%s: success", __func__);
240     return HDF_SUCCESS;
241 }
242 
CheckRawSdkIfAllocRequest007(void)243 int32_t CheckRawSdkIfAllocRequest007(void)
244 {
245     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
246     rawAcm->notifyReq = UsbRawAllocRequest(NULL, 0, rawAcm->notifyEp.maxPacketSize);
247     if (rawAcm->notifyReq) {
248         HDF_LOGE("%s: error", __func__);
249         return HDF_FAILURE;
250     }
251     HDF_LOGE("%s: success", __func__);
252     return HDF_SUCCESS;
253 }
254 
CheckRawSdkIfAllocRequest008(void)255 int32_t CheckRawSdkIfAllocRequest008(void)
256 {
257     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
258     rawAcm->notifyReq = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->notifyEp.maxPacketSize);
259     if (rawAcm->notifyReq == NULL) {
260         HDF_LOGE("%s: error", __func__);
261         return HDF_FAILURE;
262     }
263     ((struct UsbHostRequest *)(rawAcm->notifyReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
264     HDF_LOGE("%s: success", __func__);
265     return HDF_SUCCESS;
266 }
CheckRawSdkIfAllocRequest010(void)267 int32_t CheckRawSdkIfAllocRequest010(void)
268 {
269     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
270     rawAcm->isoReq = UsbRawAllocRequest(NULL, USB_ISO_PACKAT_CNT, rawAcm->isoEp.maxPacketSize);
271     if (rawAcm->isoReq == NULL) {
272         HDF_LOGE("%s: error", __func__);
273         return HDF_FAILURE;
274     }
275     ((struct UsbHostRequest *)(rawAcm->isoReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
276     HDF_LOGE("%s: success", __func__);
277     return HDF_SUCCESS;
278 }
CheckRawSdkIfAllocRequest011(void)279 int32_t CheckRawSdkIfAllocRequest011(void)
280 {
281     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
282     rawAcm->isoReq = UsbRawAllocRequest(rawAcm->devHandle, USB_ISO_PACKAT_CNT, rawAcm->isoEp.maxPacketSize);
283     if (rawAcm->isoReq == NULL) {
284         HDF_LOGE("%s: error", __func__);
285         return HDF_FAILURE;
286     }
287     ((struct UsbHostRequest *)(rawAcm->isoReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
288     HDF_LOGE("%s: success", __func__);
289     return HDF_SUCCESS;
290 }
291 
CheckRawSdkIfFreeRequest006(void)292 int32_t CheckRawSdkIfFreeRequest006(void)
293 {
294     int32_t ret;
295     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
296 
297     ret = UsbRawFreeRequest(rawAcm->isoReq);
298     if (ret != HDF_ERR_INVALID_PARAM) {
299         HDF_LOGE("%s: error", __func__);
300         return HDF_FAILURE;
301     }
302     rawAcm->isoReq = NULL;
303     HDF_LOGE("%s: success", __func__);
304     return HDF_SUCCESS;
305 }
306 
CheckRawSdkIfFillIsoRequest001(void)307 int32_t CheckRawSdkIfFillIsoRequest001(void)
308 {
309     struct UsbRawFillRequestData reqData;
310     char sendData[] = {"abcde\0"};
311     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
312     uint32_t size = strlen(sendData) + 1;
313     printf("---size:%u\n", size);
314     size = (size > rawAcm->isoEp.maxPacketSize) ? rawAcm->isoEp.maxPacketSize : size;
315     reqData.endPoint = rawAcm->isoEp.addr;
316     reqData.numIsoPackets = USB_ISO_PACKAT_CNT;
317     reqData.callback = AcmWriteIsoCallback;
318     reqData.timeout = USB_CTRL_SET_TIMEOUT;
319     reqData.buffer = (unsigned char *)sendData;
320     reqData.length = size;
321     int32_t ret = UsbRawFillIsoRequest(rawAcm->isoReq, rawAcm->devHandle, &reqData);
322     if (ret != HDF_SUCCESS) {
323         printf("%s: error++ret=%d\n", __func__, ret);
324         return HDF_FAILURE;
325     }
326     return HDF_SUCCESS;
327 }
328 
CheckRawSdkIfFillIsoRequest002(void)329 int32_t CheckRawSdkIfFillIsoRequest002(void)
330 {
331     struct UsbRawFillRequestData reqData;
332 
333     char sendData[] = {"abcde\0"};
334     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
335     uint32_t size = strlen(sendData) + 1;
336     printf("---size:%u\n", size);
337     size = (size > rawAcm->isoEp.maxPacketSize) ? rawAcm->isoEp.maxPacketSize : size;
338     reqData.endPoint = rawAcm->isoEp.addr;
339     reqData.numIsoPackets = USB_ISO_PACKAT_CNT;
340     reqData.callback = AcmWriteIsoCallback;
341     reqData.timeout = USB_CTRL_SET_TIMEOUT;
342     reqData.buffer = (unsigned char *)sendData;
343     reqData.length = size;
344 
345     int32_t ret = UsbRawFillIsoRequest(NULL, rawAcm->devHandle, &reqData);
346     if (ret != HDF_SUCCESS) {
347         printf("%s: error++ret=%d\n", __func__, ret);
348         return HDF_FAILURE;
349     }
350     return HDF_SUCCESS;
351 }
352 
CheckRawSdkIfFillIsoRequest003(void)353 int32_t CheckRawSdkIfFillIsoRequest003(void)
354 {
355     char sendData[] = {"abcde\0"};
356     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
357     uint32_t size = strlen(sendData) + 1;
358     printf("---size:%u\n", size);
359     size = (size > rawAcm->isoEp.maxPacketSize) ? rawAcm->isoEp.maxPacketSize : size;
360     int32_t ret = UsbRawFillIsoRequest(rawAcm->isoReq, rawAcm->devHandle, NULL);
361     if (ret != HDF_SUCCESS) {
362         printf("%s: error++ret=%d\n", __func__, ret);
363         return HDF_FAILURE;
364     }
365     return HDF_SUCCESS;
366 }
367 
CheckRawSdkIfFillIsoRequest004(void)368 int32_t CheckRawSdkIfFillIsoRequest004(void)
369 {
370     struct UsbRawFillRequestData reqData;
371     char sendData[] = {"abcde\0"};
372     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
373     uint32_t size = strlen(sendData) + 1;
374     printf("---size:%u\n", size);
375     size = (size > rawAcm->isoEp.maxPacketSize) ? rawAcm->isoEp.maxPacketSize : size;
376     reqData.endPoint = rawAcm->isoEp.addr;
377     reqData.numIsoPackets = USB_ISO_PACKAT_CNT;
378     reqData.callback = AcmWriteIsoCallback;
379     reqData.timeout = USB_CTRL_SET_TIMEOUT;
380     reqData.buffer = (unsigned char *)sendData;
381     reqData.length = size;
382     int32_t ret = UsbRawFillIsoRequest(rawAcm->isoReq, NULL, &reqData);
383     if (ret != HDF_SUCCESS) {
384         printf("%s: error++ret=%d\n", __func__, ret);
385         return HDF_FAILURE;
386     }
387     return HDF_SUCCESS;
388 }
389 
CheckRawSdkIfFillIsoRequest005(void)390 int32_t CheckRawSdkIfFillIsoRequest005(void)
391 {
392     struct UsbRawFillRequestData reqData;
393     uint32_t size;
394     char sendData[] = {"abcde\0"};
395     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
396     size = strlen(sendData) + 1;
397     printf("---size:%u\n", size);
398     size = (size > rawAcm->isoEp.maxPacketSize) ? rawAcm->isoEp.maxPacketSize : size;
399     reqData.endPoint = rawAcm->isoEp.addr;
400     reqData.numIsoPackets = USB_ISO_PACKAT_CNT;
401     reqData.callback = AcmWriteIsoCallback;
402     reqData.timeout = USB_CTRL_SET_TIMEOUT;
403     reqData.buffer = (unsigned char *)sendData;
404     reqData.length = size;
405     int32_t ret = UsbRawFillIsoRequest(NULL, NULL, &reqData);
406     if (ret != HDF_SUCCESS) {
407         printf("%s: error++ret=%d\n", __func__, ret);
408         return HDF_FAILURE;
409     }
410     return HDF_SUCCESS;
411 }
412 
CheckRawSdkIfFillIsoRequest006(void)413 int32_t CheckRawSdkIfFillIsoRequest006(void)
414 {
415     uint32_t size;
416     char sendData[] = {"abcde\0"};
417     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
418     size = strlen(sendData) + 1;
419     printf("---size:%u\n", size);
420     size = (size > rawAcm->isoEp.maxPacketSize) ? rawAcm->isoEp.maxPacketSize : size;
421     int32_t ret = UsbRawFillIsoRequest(NULL, NULL, NULL);
422     if (ret != HDF_SUCCESS) {
423         printf("%s: error++ret=%d\n", __func__, ret);
424         return HDF_FAILURE;
425     }
426     return HDF_SUCCESS;
427 }
CheckRawSdkIfFreeRequest001(void)428 int32_t CheckRawSdkIfFreeRequest001(void)
429 {
430     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
431 
432     for (int32_t i = 0; i < ACM_NW; i++) {
433         int32_t ret = UsbRawFreeRequest(rawAcm->wb[i].request);
434         if (ret != HDF_SUCCESS) {
435             HDF_LOGE("%s: error", __func__);
436             return HDF_FAILURE;
437         }
438         rawAcm->wb[i].request = NULL;
439     }
440     AcmWriteBufFree(rawAcm);
441     return HDF_SUCCESS;
442 }
443 
CheckRawSdkIfFreeRequest002(void)444 int32_t CheckRawSdkIfFreeRequest002(void)
445 {
446     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
447 
448     for (int32_t i = 0; i < ACM_NW; i++) {
449         int32_t ret = UsbRawFreeRequest(rawAcm->readReq[i]);
450         if (ret != HDF_SUCCESS) {
451             HDF_LOGE("%s: error", __func__);
452             return HDF_FAILURE;
453         }
454         rawAcm->readReq[i] = NULL;
455     }
456     return HDF_SUCCESS;
457 }
458 
CheckRawSdkIfFreeRequest003(void)459 int32_t CheckRawSdkIfFreeRequest003(void)
460 {
461     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
462     int32_t ret = UsbRawFreeRequest(rawAcm->ctrlReq);
463     if (ret != HDF_SUCCESS) {
464         HDF_LOGE("%s: error", __func__);
465         return HDF_FAILURE;
466     }
467     rawAcm->ctrlReq = NULL;
468     return HDF_SUCCESS;
469 }
470 
CheckRawSdkIfFreeRequest004(void)471 int32_t CheckRawSdkIfFreeRequest004(void)
472 {
473     int32_t ret;
474     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
475 
476     ret = UsbRawFreeRequest(rawAcm->notifyReq);
477     if (ret) {
478         HDF_LOGE("%s: error", __func__);
479         return HDF_FAILURE;
480     }
481     rawAcm->notifyReq = NULL;
482     HDF_LOGE("%s: success", __func__);
483     return HDF_SUCCESS;
484 }
485 
CheckRawSdkIfFreeRequest005(void)486 int32_t CheckRawSdkIfFreeRequest005(void)
487 {
488     int32_t ret;
489 
490     ret = UsbRawFreeRequest(NULL);
491     if (ret != HDF_ERR_INVALID_PARAM) {
492         HDF_LOGE("%s: error", __func__);
493         return HDF_FAILURE;
494     }
495     HDF_LOGE("%s: success", __func__);
496     return HDF_SUCCESS;
497 }
498 
CheckRawSdkIfAllocRequest009(void)499 int32_t CheckRawSdkIfAllocRequest009(void)
500 {
501     int32_t i;
502     int32_t ret;
503     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
504 
505     ret = AcmWriteBufAlloc(rawAcm);
506     if (ret) {
507         HDF_LOGE("%s: error", __func__);
508         return HDF_FAILURE;
509     }
510 
511     for (i = 0; i < ACM_NW; i++) {
512         rawAcm->wb[i].request = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->dataOutEp.maxPacketSize);
513         rawAcm->wb[i].instance = rawAcm;
514         if (rawAcm->wb[i].request == NULL) {
515             HDF_LOGE("%s: error", __func__);
516             return HDF_FAILURE;
517         }
518     }
519 
520     for (i = 0; i < ACM_NR; i++) {
521         rawAcm->readReq[i] = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->dataInEp.maxPacketSize);
522         if (rawAcm->readReq[i] == NULL) {
523             HDF_LOGE("%s: error", __func__);
524             return HDF_FAILURE;
525         }
526     }
527 
528     rawAcm->ctrlReq = UsbRawAllocRequest(rawAcm->devHandle, 0, USB_CTRL_REQ_SIZE);
529     if (rawAcm->ctrlReq == NULL) {
530         HDF_LOGE("%s: error", __func__);
531         return HDF_FAILURE;
532     }
533 
534     rawAcm->notifyReq = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->notifyEp.maxPacketSize);
535     if (rawAcm->notifyReq == NULL) {
536         HDF_LOGE("%s: error", __func__);
537         return HDF_FAILURE;
538     }
539     HDF_LOGE("%s: success", __func__);
540     return HDF_SUCCESS;
541 }
542 
CheckRawSdkIfGetDescriptor001(void)543 int32_t CheckRawSdkIfGetDescriptor001(void)
544 {
545     struct UsbRawDescriptorParam param;
546     unsigned char *data = NULL;
547     int32_t ret;
548     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
549 
550     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
551     if (data == NULL) {
552         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
553         return HDF_ERR_MALLOC_FAIL;
554     }
555 
556     ret = UsbRawGetDescriptor(NULL, rawAcm->devHandle, &param, data);
557     if (ret != HDF_ERR_INVALID_PARAM) {
558         HDF_LOGE("%s: error", __func__);
559         ret = HDF_FAILURE;
560         goto ERROR;
561     }
562     HDF_LOGE("%s: success", __func__);
563     ret = HDF_SUCCESS;
564 ERROR:
565     OsalMemFree(data);
566     data = NULL;
567 
568     return ret;
569 }
570 
CheckRawSdkIfGetDescriptor002(void)571 int32_t CheckRawSdkIfGetDescriptor002(void)
572 {
573     struct UsbRawDescriptorParam param;
574     unsigned char *data = NULL;
575     int32_t ret;
576     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
577 
578     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
579     if (data == NULL) {
580         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
581         return HDF_ERR_MALLOC_FAIL;
582     }
583 
584     ret = UsbRawGetDescriptor(rawAcm->ctrlReq, NULL, &param, data);
585     if (ret != HDF_ERR_INVALID_PARAM) {
586         HDF_LOGE("%s: error", __func__);
587         ret = HDF_FAILURE;
588         goto ERROR;
589     }
590     HDF_LOGE("%s: success", __func__);
591     ret = HDF_SUCCESS;
592 ERROR:
593     OsalMemFree(data);
594     data = NULL;
595 
596     return ret;
597 }
598 
CheckRawSdkIfGetDescriptor003(void)599 int32_t CheckRawSdkIfGetDescriptor003(void)
600 {
601     struct UsbRawDescriptorParam param;
602     unsigned char *data = NULL;
603     int32_t ret;
604 
605     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
606     if (data == NULL) {
607         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
608         return HDF_ERR_MALLOC_FAIL;
609     }
610 
611     ret = UsbRawGetDescriptor(NULL, NULL, &param, data);
612     if (ret != HDF_ERR_INVALID_PARAM) {
613         HDF_LOGE("%s: error", __func__);
614         ret = HDF_FAILURE;
615         goto ERROR;
616     }
617     HDF_LOGE("%s: success", __func__);
618     ret = HDF_SUCCESS;
619 ERROR:
620     OsalMemFree(data);
621     data = NULL;
622 
623     return ret;
624 }
625 
CheckRawSdkIfGetDescriptor004(void)626 int32_t CheckRawSdkIfGetDescriptor004(void)
627 {
628     unsigned char *data = NULL;
629     int32_t ret;
630     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
631 
632     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
633     if (data == NULL) {
634         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
635         return HDF_ERR_MALLOC_FAIL;
636     }
637 
638     ret = UsbRawGetDescriptor(rawAcm->ctrlReq, rawAcm->devHandle, NULL, data);
639     if (ret != HDF_ERR_INVALID_PARAM) {
640         HDF_LOGE("%s: error", __func__);
641         ret = HDF_FAILURE;
642         goto ERROR;
643     }
644     HDF_LOGE("%s: success", __func__);
645     ret = HDF_SUCCESS;
646 ERROR:
647     OsalMemFree(data);
648     data = NULL;
649 
650     return ret;
651 }
652 
CheckRawSdkIfGetDescriptor005(void)653 int32_t CheckRawSdkIfGetDescriptor005(void)
654 {
655     struct UsbRawDescriptorParam param;
656     int32_t ret;
657     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
658 
659     ret = UsbRawGetDescriptor(rawAcm->ctrlReq, rawAcm->devHandle, &param, NULL);
660     if (ret != HDF_ERR_INVALID_PARAM) {
661         HDF_LOGE("%s: error", __func__);
662         return HDF_FAILURE;
663     }
664     HDF_LOGE("%s: success", __func__);
665     return HDF_SUCCESS;
666 }
667 
CheckRawSdkIfGetDescriptor006(void)668 int32_t CheckRawSdkIfGetDescriptor006(void)
669 {
670     struct UsbRawDescriptorParam param;
671     unsigned char *data = NULL;
672     int32_t ret;
673     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
674 
675     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
676     if (data == NULL) {
677         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
678         return HDF_ERR_MALLOC_FAIL;
679     }
680 
681     param.descType = USB_DESC_TYPE;
682     param.descIndex = 0;
683     param.length = USB_BUFFER_MAX_SIZE;
684 
685     ret = UsbRawGetDescriptor(rawAcm->ctrlReq, rawAcm->devHandle, &param, data);
686     if (ret < 0) {
687         HDF_LOGE("%s: error", __func__);
688         ret = HDF_FAILURE;
689         goto ERROR;
690     }
691     HDF_LOGE("%s: success", __func__);
692     ret = HDF_SUCCESS;
693 ERROR:
694     OsalMemFree(data);
695     data = NULL;
696 
697     return ret;
698 }
699 
CheckRawSdkIfGetDescriptor007(void)700 int32_t CheckRawSdkIfGetDescriptor007(void)
701 {
702     unsigned char *data = NULL;
703     int32_t ret;
704     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
705 
706     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
707     if (data == NULL) {
708         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
709         return HDF_ERR_MALLOC_FAIL;
710     }
711 
712     ret = UsbRawGetDescriptor(rawAcm->ctrlReq, NULL, NULL, data);
713     if (ret != HDF_ERR_INVALID_PARAM) {
714         HDF_LOGE("%s: error", __func__);
715         ret = HDF_FAILURE;
716         goto ERROR;
717     }
718     HDF_LOGE("%s: success", __func__);
719     ret = HDF_SUCCESS;
720 ERROR:
721     OsalMemFree(data);
722     data = NULL;
723 
724     return ret;
725 }
726 
CheckRawSdkIfGetDescriptor008(void)727 int32_t CheckRawSdkIfGetDescriptor008(void)
728 {
729     int32_t ret;
730     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
731 
732     ret = UsbRawGetDescriptor(rawAcm->ctrlReq, rawAcm->devHandle, NULL, NULL);
733     if (ret != HDF_ERR_INVALID_PARAM) {
734         HDF_LOGE("%s: error", __func__);
735         return HDF_FAILURE;
736     }
737     HDF_LOGE("%s: success", __func__);
738     return HDF_SUCCESS;
739 }
740 
CheckRawSdkIfGetDescriptor009(void)741 int32_t CheckRawSdkIfGetDescriptor009(void)
742 {
743     unsigned char *data = NULL;
744     int32_t ret;
745     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
746 
747     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
748     if (data == NULL) {
749         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
750         return HDF_ERR_MALLOC_FAIL;
751     }
752 
753     ret = UsbRawGetDescriptor(NULL, rawAcm->devHandle, NULL, data);
754     if (ret != HDF_ERR_INVALID_PARAM) {
755         HDF_LOGE("%s: error", __func__);
756         ret = HDF_FAILURE;
757         goto ERROR;
758     }
759     HDF_LOGE("%s: success", __func__);
760     ret = HDF_SUCCESS;
761 ERROR:
762     OsalMemFree(data);
763     data = NULL;
764 
765     return ret;
766 }
767 
CheckRawSdkIfGetDescriptor010(void)768 int32_t CheckRawSdkIfGetDescriptor010(void)
769 {
770     struct UsbRawDescriptorParam param;
771     unsigned char data[100];
772     int32_t ret;
773     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
774 
775     param.descType = 0;
776     param.descIndex = 0;
777     param.length = sizeof(data);
778 
779     ret = UsbRawGetDescriptor(NULL, rawAcm->devHandle, &param, NULL);
780     if (ret != HDF_ERR_INVALID_PARAM) {
781         HDF_LOGE("%s: error", __func__);
782         return HDF_FAILURE;
783     }
784     HDF_LOGE("%s: success", __func__);
785     return HDF_SUCCESS;
786 }
787 
CheckRawSdkIfGetDescriptor011(void)788 int32_t CheckRawSdkIfGetDescriptor011(void)
789 {
790     struct UsbRawDescriptorParam param;
791     unsigned char data[100];
792     int32_t ret;
793     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
794 
795     param.descType = 0;
796     param.descIndex = 0;
797     param.length = sizeof(data);
798 
799     ret = UsbRawGetDescriptor(rawAcm->ctrlReq, NULL, &param, NULL);
800     if (ret != HDF_ERR_INVALID_PARAM) {
801         HDF_LOGE("%s: error", __func__);
802         return HDF_FAILURE;
803     }
804     HDF_LOGE("%s: success", __func__);
805     return HDF_SUCCESS;
806 }
807 
CheckRawSdkIfGetDescriptor012(void)808 int32_t CheckRawSdkIfGetDescriptor012(void)
809 {
810     unsigned char *data = NULL;
811     int32_t ret;
812 
813     data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
814     if (data == NULL) {
815         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
816         return HDF_ERR_MALLOC_FAIL;
817     }
818 
819     ret = UsbRawGetDescriptor(NULL, NULL, NULL, data);
820     if (ret != HDF_ERR_INVALID_PARAM) {
821         HDF_LOGE("%s: error", __func__);
822         ret = HDF_FAILURE;
823         goto ERROR;
824     }
825     HDF_LOGE("%s: success", __func__);
826     ret = HDF_SUCCESS;
827 ERROR:
828     OsalMemFree(data);
829     data = NULL;
830 
831     return ret;
832 }
833 
CheckRawSdkIfGetDescriptor013(void)834 int32_t CheckRawSdkIfGetDescriptor013(void)
835 {
836     struct UsbRawDescriptorParam param;
837     unsigned char data[100];
838     int32_t ret;
839 
840     param.descType = 0;
841     param.descIndex = 0;
842     param.length = sizeof(data);
843 
844     ret = UsbRawGetDescriptor(NULL, NULL, &param, NULL);
845     if (ret != HDF_ERR_INVALID_PARAM) {
846         HDF_LOGE("%s: error", __func__);
847         return HDF_FAILURE;
848     }
849     HDF_LOGE("%s: success", __func__);
850     return HDF_SUCCESS;
851 }
852 
CheckRawSdkIfGetDescriptor014(void)853 int32_t CheckRawSdkIfGetDescriptor014(void)
854 {
855     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
856     int32_t ret = UsbRawGetDescriptor(NULL, rawAcm->devHandle, NULL, NULL);
857     if (ret != HDF_ERR_INVALID_PARAM) {
858         HDF_LOGE("%s: error", __func__);
859         return HDF_FAILURE;
860     }
861     return HDF_SUCCESS;
862 }
863 
CheckRawSdkIfGetDescriptor015(void)864 int32_t CheckRawSdkIfGetDescriptor015(void)
865 {
866     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
867     int32_t ret = UsbRawGetDescriptor(rawAcm->ctrlReq, NULL, NULL, NULL);
868     if (ret != HDF_ERR_INVALID_PARAM) {
869         HDF_LOGE("%s: error", __func__);
870         return HDF_FAILURE;
871     }
872     HDF_LOGE("%s: success", __func__);
873     return HDF_SUCCESS;
874 }
875 
CheckRawSdkIfGetDescriptor016(void)876 int32_t CheckRawSdkIfGetDescriptor016(void)
877 {
878     int32_t ret = UsbRawGetDescriptor(NULL, NULL, NULL, NULL);
879     if (ret != HDF_ERR_INVALID_PARAM) {
880         HDF_LOGE("%s: error", __func__);
881         return HDF_FAILURE;
882     }
883     return HDF_SUCCESS;
884 }
885 
CheckRawSdkIfFillBulkRequest001(void)886 int32_t CheckRawSdkIfFillBulkRequest001(void)
887 {
888     struct UsbRawFillRequestData reqData;
889     char sendData[] = {"abcde\0"};
890     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
891 
892     uint32_t size = strlen(sendData) + 1;
893     printf("---size:%u\n", size);
894 
895     size = (size > rawAcm->dataOutEp.maxPacketSize) ? rawAcm->dataOutEp.maxPacketSize : size;
896     struct RawWb *snd = &rawAcm->wb[0];
897     snd->len = (int)size;
898     int32_t ret = memcpy_s(snd->buf, rawAcm->dataOutEp.maxPacketSize, sendData, size);
899     if (ret != EOK) {
900         HDF_LOGE("%s: memcpy_s fail", __func__);
901         return HDF_FAILURE;
902     }
903     rawAcm->transmitting++;
904     reqData.endPoint = rawAcm->dataOutEp.addr;
905     reqData.numIsoPackets = 0;
906     reqData.callback = AcmWriteBulkCallback;
907     reqData.userData = (void *)snd;
908     reqData.timeout = USB_CTRL_SET_TIMEOUT;
909     reqData.buffer = snd->buf;
910     reqData.length = snd->len;
911     printf("maxPacketSize:%d\n", rawAcm->dataOutEp.maxPacketSize);
912     ret = UsbRawFillBulkRequest(snd->request, rawAcm->devHandle, &reqData);
913     if (ret != HDF_SUCCESS) {
914         printf("%s: error++ret=%d\n", __func__, ret);
915         return HDF_FAILURE;
916     }
917     return HDF_SUCCESS;
918 }
919 
CheckRawSdkIfFillBulkRequest002(void)920 int32_t CheckRawSdkIfFillBulkRequest002(void)
921 {
922     struct UsbRawFillRequestData reqData;
923     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
924     uint32_t size = rawAcm->dataInEp.maxPacketSize;
925 
926     reqData.endPoint = rawAcm->dataInEp.addr;
927     reqData.numIsoPackets = 0;
928     reqData.callback = AcmReadBulkCallback;
929     reqData.userData = (void *)rawAcm;
930     reqData.timeout = USB_CTRL_SET_TIMEOUT;
931     reqData.length = size;
932 
933     int32_t ret = UsbRawFillBulkRequest(rawAcm->readReq[0], rawAcm->devHandle, &reqData);
934     if (ret != HDF_SUCCESS) {
935         HDF_LOGE("%s: error", __func__);
936         return HDF_FAILURE;
937     }
938     return HDF_SUCCESS;
939 }
940 
CheckRawSdkIfFillInterruptRequest001(void)941 int32_t CheckRawSdkIfFillInterruptRequest001(void)
942 {
943     struct UsbRawFillRequestData fillRequestData;
944     int32_t ret;
945     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
946     uint32_t size = rawAcm->notifyEp.maxPacketSize;
947 
948     fillRequestData.endPoint = rawAcm->notifyEp.addr;
949     fillRequestData.length = size;
950     fillRequestData.numIsoPackets = 0;
951     fillRequestData.callback = AcmNotifyReqCallback;
952     fillRequestData.userData = (void *)rawAcm;
953     fillRequestData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
954 
955     ret = UsbRawFillInterruptRequest(rawAcm->notifyReq, rawAcm->devHandle, &fillRequestData);
956     if (ret) {
957         HDF_LOGE("%s: error", __func__);
958         return HDF_FAILURE;
959     }
960     HDF_LOGE("%s: success", __func__);
961     return HDF_SUCCESS;
962 }
963 
CheckRawSdkIfFillInterruptRequest002(void)964 int32_t CheckRawSdkIfFillInterruptRequest002(void)
965 {
966     struct UsbRawFillRequestData fillRequestData;
967     int32_t ret;
968     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
969     uint32_t size = rawAcm->notifyEp.maxPacketSize;
970 
971     fillRequestData.endPoint = rawAcm->notifyEp.addr;
972     fillRequestData.length = size;
973     fillRequestData.numIsoPackets = 0;
974     fillRequestData.callback = AcmNotifyReqCallback;
975     fillRequestData.userData = (void *)rawAcm;
976     fillRequestData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
977 
978     ret = UsbRawFillInterruptRequest(NULL, rawAcm->devHandle, &fillRequestData);
979     if (ret != HDF_ERR_INVALID_PARAM) {
980         HDF_LOGE("%s: error", __func__);
981         return HDF_FAILURE;
982     }
983     HDF_LOGE("%s: success", __func__);
984     return HDF_SUCCESS;
985 }
986 
CheckRawSdkIfFillInterruptRequest003(void)987 int32_t CheckRawSdkIfFillInterruptRequest003(void)
988 {
989     struct UsbRawFillRequestData fillRequestData;
990     int32_t ret;
991     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
992     uint32_t size = rawAcm->notifyEp.maxPacketSize;
993 
994     fillRequestData.endPoint = rawAcm->notifyEp.addr;
995     fillRequestData.length = size;
996     fillRequestData.numIsoPackets = 0;
997     fillRequestData.callback = AcmNotifyReqCallback;
998     fillRequestData.userData = (void *)rawAcm;
999     fillRequestData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1000 
1001     ret = UsbRawFillInterruptRequest(rawAcm->notifyReq, NULL, &fillRequestData);
1002     if (ret != HDF_ERR_INVALID_PARAM) {
1003         HDF_LOGE("%s: error", __func__);
1004         return HDF_FAILURE;
1005     }
1006     HDF_LOGE("%s: success", __func__);
1007     return HDF_SUCCESS;
1008 }
1009 
CheckRawSdkIfFillInterruptRequest004(void)1010 int32_t CheckRawSdkIfFillInterruptRequest004(void)
1011 {
1012     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1013     int32_t ret = UsbRawFillInterruptRequest(rawAcm->notifyReq, rawAcm->devHandle, NULL);
1014     if (ret != HDF_ERR_INVALID_PARAM) {
1015         HDF_LOGE("%s: error", __func__);
1016         return HDF_FAILURE;
1017     }
1018     return HDF_SUCCESS;
1019 }
1020 
CheckRawSdkIfFillControlRequest001(void)1021 int32_t CheckRawSdkIfFillControlRequest001(void)
1022 {
1023     struct UsbRawFillRequestData fillRequestData;
1024     int32_t ret;
1025     int32_t completed = 0;
1026     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1027 
1028     fillRequestData.callback = AcmCtrlReqCallback;
1029     fillRequestData.userData = &completed;
1030     fillRequestData.timeout = USB_CTRL_SET_TIMEOUT;
1031 
1032     ret = UsbRawFillControlRequest(rawAcm->ctrlReq, rawAcm->devHandle, &fillRequestData);
1033     if (ret) {
1034         HDF_LOGE("%s: error", __func__);
1035         return HDF_FAILURE;
1036     }
1037     HDF_LOGE("%s: success", __func__);
1038     return HDF_SUCCESS;
1039 }
1040 
CheckRawSdkIfFillControlRequest002(void)1041 int32_t CheckRawSdkIfFillControlRequest002(void)
1042 {
1043     struct UsbRawFillRequestData fillRequestData;
1044     int32_t ret;
1045     int32_t completed = 0;
1046     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1047 
1048     fillRequestData.callback = AcmCtrlReqCallback;
1049     fillRequestData.userData = &completed;
1050     fillRequestData.timeout = USB_CTRL_SET_TIMEOUT;
1051 
1052     ret = UsbRawFillControlRequest(NULL, rawAcm->devHandle, &fillRequestData);
1053     if (ret != HDF_ERR_INVALID_PARAM) {
1054         HDF_LOGE("%s: error", __func__);
1055         return HDF_FAILURE;
1056     }
1057     HDF_LOGE("%s: success", __func__);
1058     return HDF_SUCCESS;
1059 }
1060 
CheckRawSdkIfFillControlRequest003(void)1061 int32_t CheckRawSdkIfFillControlRequest003(void)
1062 {
1063     struct UsbRawFillRequestData fillRequestData;
1064     int32_t ret;
1065     int32_t completed = 0;
1066     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1067 
1068     fillRequestData.callback = AcmCtrlReqCallback;
1069     fillRequestData.userData = &completed;
1070     fillRequestData.timeout = USB_CTRL_SET_TIMEOUT;
1071 
1072     ret = UsbRawFillControlRequest(rawAcm->ctrlReq, NULL, &fillRequestData);
1073     if (ret != HDF_ERR_INVALID_PARAM) {
1074         HDF_LOGE("%s: error", __func__);
1075         return HDF_FAILURE;
1076     }
1077     HDF_LOGE("%s: success", __func__);
1078     return HDF_SUCCESS;
1079 }
1080 
CheckRawSdkIfFillControlRequest004(void)1081 int32_t CheckRawSdkIfFillControlRequest004(void)
1082 {
1083     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1084     int32_t ret = UsbRawFillControlRequest(rawAcm->ctrlReq, rawAcm->devHandle, NULL);
1085     if (ret != HDF_ERR_INVALID_PARAM) {
1086         HDF_LOGE("%s: error", __func__);
1087         return HDF_FAILURE;
1088     }
1089     return HDF_SUCCESS;
1090 }
1091 
CheckRawSdkIfFillControlRequest005(void)1092 int32_t CheckRawSdkIfFillControlRequest005(void)
1093 {
1094     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1095     int32_t ret = UsbRawFillControlRequest(NULL, rawAcm->devHandle, NULL);
1096     if (ret != HDF_ERR_INVALID_PARAM) {
1097         HDF_LOGE("%s: error", __func__);
1098         return HDF_FAILURE;
1099     }
1100     return HDF_SUCCESS;
1101 }
1102 
CheckRawSdkIfFillControlRequest006(void)1103 int32_t CheckRawSdkIfFillControlRequest006(void)
1104 {
1105     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1106     if (rawAcm == NULL) {
1107         HDF_LOGE("%s: get io acm failed", __func__);
1108         return HDF_FAILURE;
1109     }
1110 
1111     int32_t ret = UsbRawFillControlRequest(rawAcm->ctrlReq, NULL, NULL);
1112     if (ret != HDF_ERR_INVALID_PARAM) {
1113         HDF_LOGE("%s: error", __func__);
1114         return HDF_FAILURE;
1115     }
1116     return HDF_SUCCESS;
1117 }
1118 
CheckRawSdkIfFillControlRequest007(void)1119 int32_t CheckRawSdkIfFillControlRequest007(void)
1120 {
1121     int32_t ret = UsbRawFillControlRequest(NULL, NULL, NULL);
1122     if (ret != HDF_ERR_INVALID_PARAM) {
1123         HDF_LOGE("%s: error", __func__);
1124         return HDF_FAILURE;
1125     }
1126     return HDF_SUCCESS;
1127 }
1128 
CheckRawSdkIfFillControlRequest008(void)1129 int32_t CheckRawSdkIfFillControlRequest008(void)
1130 {
1131     struct UsbRawFillRequestData fillRequestData;
1132     int32_t ret;
1133     int32_t completed = 0;
1134 
1135     fillRequestData.callback = AcmCtrlReqCallback;
1136     fillRequestData.userData = &completed;
1137     fillRequestData.timeout = USB_CTRL_SET_TIMEOUT;
1138 
1139     ret = UsbRawFillControlRequest(NULL, NULL, &fillRequestData);
1140     if (ret != HDF_ERR_INVALID_PARAM) {
1141         HDF_LOGE("%s: error", __func__);
1142         return HDF_FAILURE;
1143     }
1144     HDF_LOGE("%s: success", __func__);
1145     return HDF_SUCCESS;
1146 }
1147 
CheckRawSdkIfFillControlSetup001(void)1148 int32_t CheckRawSdkIfFillControlSetup001(void)
1149 {
1150     struct UsbControlRequestData ctrlReq;
1151     int32_t ret;
1152     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1153 
1154     rawAcm->lineCoding.dwDTERate = CPU_TO_LE32(DATARATE);
1155     rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1156     rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1157     rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1158 
1159     ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1160     ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING;
1161     ctrlReq.value = CPU_TO_LE16(0);
1162     ctrlReq.index = 0;
1163     ctrlReq.data = (unsigned char *)&rawAcm->lineCoding;
1164     ctrlReq.length = sizeof(struct UsbCdcLineCoding);
1165     ctrlReq.timeout = USB_CTRL_SET_TIMEOUT;
1166 
1167     ret = UsbRawFillControlSetup(NULL, &ctrlReq);
1168     if (ret != HDF_ERR_INVALID_PARAM) {
1169         HDF_LOGE("%s: error", __func__);
1170         return HDF_FAILURE;
1171     }
1172     HDF_LOGE("%s: success", __func__);
1173     return HDF_SUCCESS;
1174 }
1175 
CheckRawSdkIfFillControlSetup002(void)1176 int32_t CheckRawSdkIfFillControlSetup002(void)
1177 {
1178     unsigned char *setup = NULL;
1179     int32_t ret;
1180 
1181     setup = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
1182     if (setup == NULL) {
1183         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
1184         return HDF_ERR_MALLOC_FAIL;
1185     }
1186 
1187     ret = UsbRawFillControlSetup(setup, NULL);
1188     if (ret != HDF_ERR_INVALID_PARAM) {
1189         HDF_LOGE("%s: error", __func__);
1190         ret = HDF_FAILURE;
1191         goto ERROR;
1192     }
1193     HDF_LOGE("%s: success", __func__);
1194     ret = HDF_SUCCESS;
1195 ERROR:
1196     OsalMemFree(setup);
1197     setup = NULL;
1198 
1199     return ret;
1200 }
1201 
CheckRawSdkIfFillControlSetup003(void)1202 int32_t CheckRawSdkIfFillControlSetup003(void)
1203 {
1204     int32_t ret;
1205 
1206     ret = UsbRawFillControlSetup(NULL, NULL);
1207     if (ret != HDF_ERR_INVALID_PARAM) {
1208         HDF_LOGE("%s: error", __func__);
1209         return HDF_FAILURE;
1210     }
1211     HDF_LOGE("%s: success", __func__);
1212     return HDF_SUCCESS;
1213 }
1214 
CheckRawSdkIfFillControlSetup004(void)1215 int32_t CheckRawSdkIfFillControlSetup004(void)
1216 {
1217     struct UsbControlRequestData ctrlReq;
1218     unsigned char *setup = NULL;
1219     int32_t ret;
1220     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1221 
1222     rawAcm->lineCoding.dwDTERate = CPU_TO_LE32(DATARATE);
1223     rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1224     rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1225     rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1226 
1227     ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1228     ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING;
1229     ctrlReq.value = CPU_TO_LE16(0);
1230     ctrlReq.index = 0;
1231     ctrlReq.data = (unsigned char *)&rawAcm->lineCoding;
1232     ctrlReq.length = sizeof(struct UsbCdcLineCoding);
1233     ctrlReq.timeout = USB_CTRL_SET_TIMEOUT;
1234 
1235     setup = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
1236     if (setup == NULL) {
1237         HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
1238         return HDF_ERR_MALLOC_FAIL;
1239     }
1240 
1241     ret = UsbRawFillControlSetup(setup, &ctrlReq);
1242     if (ret) {
1243         HDF_LOGE("%s: error", __func__);
1244         ret = HDF_FAILURE;
1245         goto ERROR;
1246     }
1247     HDF_LOGE("%s: success", __func__);
1248 
1249 ERROR:
1250     OsalMemFree(setup);
1251     setup = NULL;
1252 
1253     return ret;
1254 }
1255 
CheckRawSdkIfSendControlRequest001(void)1256 int32_t CheckRawSdkIfSendControlRequest001(void)
1257 {
1258     struct UsbControlRequestData ctrlReq;
1259     int32_t ret;
1260     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1261 
1262     rawAcm->lineCoding.dwDTERate = CPU_TO_LE32(DATARATE);
1263     rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1264     rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1265     rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1266     ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1267     ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING;
1268     ctrlReq.value = CPU_TO_LE16(0);
1269     ctrlReq.index = 0;
1270     ctrlReq.data = (unsigned char *)&rawAcm->lineCoding;
1271     ctrlReq.length = sizeof(struct UsbCdcLineCoding);
1272     ctrlReq.timeout = USB_CTRL_SET_TIMEOUT;
1273 
1274     ret = UsbRawSendControlRequest(NULL, rawAcm->devHandle, &ctrlReq);
1275     if (ret != HDF_ERR_INVALID_PARAM) {
1276         HDF_LOGE("%s: error", __func__);
1277         return HDF_FAILURE;
1278     }
1279     HDF_LOGE("%s: success", __func__);
1280     return HDF_SUCCESS;
1281 }
1282 
CheckRawSdkIfSendControlRequest002(void)1283 int32_t CheckRawSdkIfSendControlRequest002(void)
1284 {
1285     struct UsbControlRequestData ctrlReq;
1286     int32_t ret;
1287     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1288 
1289     rawAcm->lineCoding.dwDTERate = CPU_TO_LE32(DATARATE);
1290     rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1291     rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1292     rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1293     ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1294     ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING;
1295     ctrlReq.value = CPU_TO_LE16(0);
1296     ctrlReq.index = 0;
1297     ctrlReq.data = (unsigned char *)&rawAcm->lineCoding;
1298     ctrlReq.length = sizeof(struct UsbCdcLineCoding);
1299     ctrlReq.timeout = USB_CTRL_SET_TIMEOUT;
1300 
1301     ret = UsbRawSendControlRequest(rawAcm->ctrlReq, NULL, &ctrlReq);
1302     if (ret != HDF_ERR_INVALID_PARAM) {
1303         HDF_LOGE("%s: error", __func__);
1304         return HDF_FAILURE;
1305     }
1306     HDF_LOGE("%s: success", __func__);
1307     return HDF_SUCCESS;
1308 }
1309 
CheckRawSdkIfSendControlRequest003(void)1310 int32_t CheckRawSdkIfSendControlRequest003(void)
1311 {
1312     int32_t ret;
1313     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1314     ret = UsbRawSendControlRequest(rawAcm->ctrlReq, rawAcm->devHandle, NULL);
1315     if (ret != HDF_ERR_INVALID_PARAM) {
1316         HDF_LOGE("%s: error", __func__);
1317         return HDF_FAILURE;
1318     }
1319     HDF_LOGE("%s: success", __func__);
1320     return HDF_SUCCESS;
1321 }
1322 
CheckRawSdkIfSendControlRequest004(void)1323 int32_t CheckRawSdkIfSendControlRequest004(void)
1324 {
1325     struct UsbControlRequestData ctrlReq;
1326     int32_t ret;
1327     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1328 
1329     rawAcm->lineCoding.dwDTERate = CPU_TO_LE32(DATARATE);
1330     rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1331     rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1332     rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1333     ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1334     ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING;
1335     ctrlReq.value = CPU_TO_LE16(0);
1336     ctrlReq.index = 2;
1337     ctrlReq.data = (unsigned char *)&rawAcm->lineCoding;
1338     ctrlReq.length = sizeof(struct UsbCdcLineCoding);
1339     ctrlReq.timeout = USB_CTRL_SET_TIMEOUT;
1340 
1341     ret = UsbRawSendControlRequest(rawAcm->ctrlReq, rawAcm->devHandle, &ctrlReq);
1342     if (ret < 0) {
1343         HDF_LOGE("%s: error", __func__);
1344         return HDF_FAILURE;
1345     }
1346     HDF_LOGE("%s: success", __func__);
1347     return HDF_SUCCESS;
1348 }
1349 
CheckRawSdkIfSendControlRequest005(void)1350 int32_t CheckRawSdkIfSendControlRequest005(void)
1351 {
1352     struct UsbControlRequestData ctrlReq;
1353     int32_t ret;
1354     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1355 
1356     rawAcm->lineCoding.dwDTERate = CPU_TO_LE32(DATARATE);
1357     rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS;
1358     rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY;
1359     rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH;
1360     ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE;
1361     ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING;
1362     ctrlReq.value = CPU_TO_LE16(0);
1363     ctrlReq.index = 0;
1364     ctrlReq.data = (unsigned char *)&rawAcm->lineCoding;
1365     ctrlReq.length = sizeof(struct UsbCdcLineCoding);
1366     ctrlReq.timeout = USB_CTRL_SET_TIMEOUT;
1367 
1368     ret = UsbRawSendControlRequest(NULL, NULL, &ctrlReq);
1369     if (ret != HDF_ERR_INVALID_PARAM) {
1370         HDF_LOGE("%s: error", __func__);
1371         return HDF_FAILURE;
1372     }
1373     HDF_LOGE("%s: success", __func__);
1374     return HDF_SUCCESS;
1375 }
1376 
CheckRawSdkIfSendControlRequest006(void)1377 int32_t CheckRawSdkIfSendControlRequest006(void)
1378 {
1379     int32_t ret;
1380     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1381 
1382     ret = UsbRawSendControlRequest(NULL, rawAcm->devHandle, NULL);
1383     if (ret != HDF_ERR_INVALID_PARAM) {
1384         HDF_LOGE("%s: error", __func__);
1385         return HDF_FAILURE;
1386     }
1387     HDF_LOGE("%s: success", __func__);
1388     return HDF_SUCCESS;
1389 }
1390 
CheckRawSdkIfSendControlRequest007(void)1391 int32_t CheckRawSdkIfSendControlRequest007(void)
1392 {
1393     int32_t ret;
1394     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1395 
1396     ret = UsbRawSendControlRequest(rawAcm->ctrlReq, NULL, NULL);
1397     if (ret != HDF_ERR_INVALID_PARAM) {
1398         HDF_LOGE("%s: error", __func__);
1399         return HDF_FAILURE;
1400     }
1401     HDF_LOGE("%s: success", __func__);
1402     return HDF_SUCCESS;
1403 }
1404 
CheckRawSdkIfSendBulkRequest001(void)1405 int32_t CheckRawSdkIfSendBulkRequest001(void)
1406 {
1407     struct UsbRequestData reqData;
1408     int32_t ret;
1409     int32_t i;
1410     uint32_t size;
1411     char sendData[] = {"abcd\0"};
1412     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1413 
1414     size = strlen(sendData) + 1;
1415     size = (size > rawAcm->dataOutEp.maxPacketSize) ? rawAcm->dataOutEp.maxPacketSize : size;
1416 
1417     for (i = 0; i < 1; i++) {
1418         struct RawWb *snd = &rawAcm->wb[i];
1419         snd->len = (int)size;
1420         ret = memcpy_s(snd->buf, rawAcm->dataOutEp.maxPacketSize, sendData, size);
1421         if (ret) {
1422             HDF_LOGE("%s: memcpy_s fail", __func__);
1423             return HDF_FAILURE;
1424         }
1425         rawAcm->transmitting++;
1426 
1427         reqData.endPoint = rawAcm->dataOutEp.addr;
1428         reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1429         reqData.data = snd->buf;
1430         reqData.length = snd->len;
1431         reqData.requested = (int32_t *)&size;
1432     }
1433 
1434     for (i = 0; i < 1; i++) {
1435         struct RawWb *snd = &rawAcm->wb[i];
1436         printf("UsbRawSendBulkRequest i = [%d]\n", i);
1437         ret = UsbRawSendBulkRequest(snd->request, rawAcm->devHandle, &reqData);
1438         if (ret) {
1439             printf("%s: error+ret:%d", __func__, ret);
1440             return HDF_FAILURE;
1441         }
1442     }
1443     HDF_LOGE("%s: success", __func__);
1444     return HDF_SUCCESS;
1445 }
1446 
CheckRawSdkIfSendBulkRequest002(void)1447 int32_t CheckRawSdkIfSendBulkRequest002(void)
1448 {
1449     struct UsbRequestData reqData;
1450     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1451     uint32_t size = rawAcm->dataInEp.maxPacketSize;
1452 
1453     reqData.endPoint = rawAcm->dataInEp.addr;
1454     reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1455     reqData.length = size;
1456     reqData.data = ((struct UsbRawRequest *)rawAcm->readReq[0])->buffer;
1457     reqData.requested = (int32_t *)&size;
1458 
1459     int32_t ret = UsbRawSendBulkRequest(rawAcm->readReq[0], rawAcm->devHandle, &reqData);
1460     if (ret != HDF_SUCCESS) {
1461         HDF_LOGE("%s: error", __func__);
1462         return HDF_FAILURE;
1463     }
1464     return HDF_SUCCESS;
1465 }
1466 
CheckRawSdkIfSendBulkRequest003(void)1467 int32_t CheckRawSdkIfSendBulkRequest003(void)
1468 {
1469     struct UsbRequestData reqData;
1470     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1471     uint32_t size = rawAcm->dataInEp.maxPacketSize;
1472 
1473     reqData.endPoint = rawAcm->dataInEp.addr;
1474     reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1475     reqData.length = size;
1476     reqData.data = ((struct UsbRawRequest *)rawAcm->readReq[0])->buffer;
1477     reqData.requested = (int32_t *)&size;
1478 
1479     int32_t ret = UsbRawSendBulkRequest(NULL, rawAcm->devHandle, &reqData);
1480     if (ret != HDF_ERR_INVALID_PARAM) {
1481         HDF_LOGE("%s: error", __func__);
1482         return HDF_FAILURE;
1483     }
1484     return HDF_SUCCESS;
1485 }
1486 
CheckRawSdkIfSendBulkRequest004(void)1487 int32_t CheckRawSdkIfSendBulkRequest004(void)
1488 {
1489     struct UsbRequestData reqData;
1490     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1491     uint32_t size = rawAcm->dataInEp.maxPacketSize;
1492 
1493     reqData.endPoint = rawAcm->dataInEp.addr;
1494     reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1495     reqData.length = size;
1496     reqData.data = ((struct UsbRawRequest *)rawAcm->readReq[0])->buffer;
1497     reqData.requested = (int32_t *)&size;
1498 
1499     int32_t ret = UsbRawSendBulkRequest(rawAcm->readReq[0], NULL, &reqData);
1500     if (ret != HDF_ERR_INVALID_PARAM) {
1501         HDF_LOGE("%s: error", __func__);
1502         return HDF_FAILURE;
1503     }
1504     return HDF_SUCCESS;
1505 }
1506 
CheckRawSdkIfSendBulkRequest005(void)1507 int32_t CheckRawSdkIfSendBulkRequest005(void)
1508 {
1509     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1510 
1511     int32_t ret = UsbRawSendBulkRequest(rawAcm->readReq[0], rawAcm->devHandle, NULL);
1512     if (ret != HDF_ERR_INVALID_PARAM) {
1513         HDF_LOGE("%s: error", __func__);
1514         return HDF_FAILURE;
1515     }
1516     return HDF_SUCCESS;
1517 }
1518 
CheckRawSdkIfSendInterruptRequest001(void)1519 int32_t CheckRawSdkIfSendInterruptRequest001(void)
1520 {
1521     struct UsbRequestData reqData;
1522     int32_t ret;
1523     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1524     uint32_t size = rawAcm->notifyEp.maxPacketSize;
1525 
1526     reqData.endPoint = rawAcm->notifyEp.addr;
1527     reqData.length = size;
1528     reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1529     reqData.data = ((struct UsbRawRequest *)rawAcm->notifyReq)->buffer;
1530     reqData.requested = (int32_t *)&size;
1531     ret = UsbRawSendInterruptRequest(rawAcm->notifyReq, rawAcm->devHandle, &reqData);
1532     if (ret) {
1533         HDF_LOGE("%s: error", __func__);
1534         return HDF_FAILURE;
1535     }
1536     HDF_LOGE("%s: success", __func__);
1537     return HDF_SUCCESS;
1538 }
1539 
CheckRawSdkIfSendInterruptRequest002(void)1540 int32_t CheckRawSdkIfSendInterruptRequest002(void)
1541 {
1542     struct UsbRequestData reqData;
1543     int32_t ret;
1544     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1545     uint32_t size = rawAcm->notifyEp.maxPacketSize;
1546 
1547     reqData.endPoint = rawAcm->notifyEp.addr;
1548     reqData.length = size;
1549     reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1550     reqData.data = ((struct UsbRawRequest *)rawAcm->notifyReq)->buffer;
1551     reqData.requested = (int32_t *)&size;
1552 
1553     ret = UsbRawSendInterruptRequest(NULL, rawAcm->devHandle, &reqData);
1554     if (ret != HDF_ERR_INVALID_PARAM) {
1555         HDF_LOGE("%s: error", __func__);
1556         return HDF_FAILURE;
1557     }
1558     HDF_LOGE("%s: success", __func__);
1559     return HDF_SUCCESS;
1560 }
1561 
CheckRawSdkIfSendInterruptRequest003(void)1562 int32_t CheckRawSdkIfSendInterruptRequest003(void)
1563 {
1564     struct UsbRequestData reqData;
1565     int32_t ret;
1566     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1567     uint32_t size = rawAcm->notifyEp.maxPacketSize;
1568 
1569     reqData.endPoint = rawAcm->notifyEp.addr;
1570     reqData.length = size;
1571     reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1572     reqData.data = ((struct UsbRawRequest *)rawAcm->notifyReq)->buffer;
1573     reqData.requested = (int32_t *)&size;
1574 
1575     ret = UsbRawSendInterruptRequest(rawAcm->notifyReq, NULL, &reqData);
1576     if (ret != HDF_ERR_INVALID_PARAM) {
1577         HDF_LOGE("%s: error", __func__);
1578         return HDF_FAILURE;
1579     }
1580     HDF_LOGE("%s: success", __func__);
1581     return HDF_SUCCESS;
1582 }
1583 
CheckRawSdkIfSendInterruptRequest004(void)1584 int32_t CheckRawSdkIfSendInterruptRequest004(void)
1585 {
1586     int32_t ret;
1587     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1588 
1589     ret = UsbRawSendInterruptRequest(rawAcm->notifyReq, rawAcm->devHandle, NULL);
1590     if (ret != HDF_ERR_INVALID_PARAM) {
1591         HDF_LOGE("%s: error", __func__);
1592         return HDF_FAILURE;
1593     }
1594     HDF_LOGE("%s: success", __func__);
1595     return HDF_SUCCESS;
1596 }
1597 
CheckRawSdkIfFillBulkRequest003(void)1598 int32_t CheckRawSdkIfFillBulkRequest003(void)
1599 {
1600     struct UsbRawFillRequestData reqData;
1601     uint32_t size;
1602     char sendData[] = {"abcde\0"};
1603     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1604     size = strlen(sendData) + 1;
1605     size = (size > rawAcm->dataOutEp.maxPacketSize) ? rawAcm->dataOutEp.maxPacketSize : size;
1606 
1607     for (int32_t i = 0; i < ACM_NW; i++) {
1608         struct RawWb *snd = &rawAcm->wb[i];
1609         snd->len = (int)size;
1610         int32_t ret = memcpy_s(snd->buf, rawAcm->dataOutEp.maxPacketSize, sendData, size);
1611         if (ret != EOK) {
1612             HDF_LOGE("%s: memcpy_s fail", __func__);
1613             return HDF_FAILURE;
1614         }
1615         rawAcm->transmitting++;
1616 
1617         reqData.endPoint = rawAcm->dataOutEp.addr;
1618         reqData.numIsoPackets = 0;
1619         reqData.callback = AcmWriteBulkCallback;
1620         reqData.userData = (void *)snd;
1621         reqData.timeout = USB_CTRL_SET_TIMEOUT;
1622         reqData.buffer = snd->buf;
1623         reqData.length = snd->len;
1624 
1625         ret = UsbRawFillBulkRequest(snd->request, rawAcm->devHandle, &reqData);
1626         if (ret != HDF_SUCCESS) {
1627             HDF_LOGE("%s: error", __func__);
1628             return HDF_FAILURE;
1629         }
1630     }
1631     return HDF_SUCCESS;
1632 }
1633 
CheckRawSdkIfFillBulkRequest004(void)1634 int32_t CheckRawSdkIfFillBulkRequest004(void)
1635 {
1636     struct UsbRawFillRequestData reqData;
1637     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1638     uint32_t size = rawAcm->dataInEp.maxPacketSize;
1639 
1640     for (int32_t i = 0; i < ACM_NW; i++) {
1641         reqData.endPoint = rawAcm->dataInEp.addr;
1642         reqData.numIsoPackets = 0;
1643         reqData.callback = AcmReadBulkCallback;
1644         reqData.userData = (void *)rawAcm;
1645         reqData.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
1646         reqData.length = size;
1647         int32_t ret = UsbRawFillBulkRequest(rawAcm->readReq[i], rawAcm->devHandle, &reqData);
1648         if (ret != HDF_SUCCESS) {
1649             HDF_LOGE("%s: error", __func__);
1650             return HDF_FAILURE;
1651         }
1652     }
1653     return HDF_SUCCESS;
1654 }
1655 
CheckRawSdkIfFillInterruptRequest005(void)1656 int32_t CheckRawSdkIfFillInterruptRequest005(void)
1657 {
1658     struct UsbRawFillRequestData fillRequestData;
1659     int32_t ret;
1660     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1661     uint32_t size = rawAcm->notifyEp.maxPacketSize;
1662     fillRequestData.endPoint = rawAcm->notifyEp.addr;
1663     fillRequestData.length = size;
1664     fillRequestData.numIsoPackets = 0;
1665     fillRequestData.callback = AcmNotifyReqCallback;
1666     fillRequestData.userData = (void *)rawAcm;
1667     fillRequestData.timeout = USB_CTRL_SET_TIMEOUT;
1668     ret = UsbRawFillInterruptRequest(rawAcm->notifyReq, rawAcm->devHandle, &fillRequestData);
1669     if (ret) {
1670         HDF_LOGE("%s: error", __func__);
1671         return HDF_FAILURE;
1672     }
1673     HDF_LOGE("%s: success", __func__);
1674     return HDF_SUCCESS;
1675 }
1676 
CheckRawSdkIfSubmitRequest001(void)1677 int32_t CheckRawSdkIfSubmitRequest001(void)
1678 {
1679     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1680 
1681     for (int32_t i = 0; i < ACM_NW; i++) {
1682         struct RawWb *snd = &rawAcm->wb[i];
1683         printf("UsbRawSubmitRequest i = [%d]\n", i);
1684         int32_t ret = UsbRawSubmitRequest(snd->request);
1685         if (ret != HDF_SUCCESS) {
1686             HDF_LOGE("%s: error", __func__);
1687             return HDF_FAILURE;
1688         }
1689     }
1690     return HDF_SUCCESS;
1691 }
1692 
CheckRawSdkIfSubmitRequest002(void)1693 int32_t CheckRawSdkIfSubmitRequest002(void)
1694 {
1695     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1696 
1697     for (int32_t i = 0; i < ACM_NW; i++) {
1698         printf("UsbRawSubmitRequest i = [%d]\n", i);
1699         int32_t ret = UsbRawSubmitRequest(rawAcm->readReq[i]);
1700         if (ret != HDF_SUCCESS) {
1701             HDF_LOGE("%s: error", __func__);
1702             return HDF_FAILURE;
1703         }
1704     }
1705     return HDF_SUCCESS;
1706 }
1707 
CheckRawSdkIfSubmitRequest003(void)1708 int32_t CheckRawSdkIfSubmitRequest003(void)
1709 {
1710     int32_t ret;
1711     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1712 
1713     ret = UsbRawSubmitRequest(rawAcm->notifyReq);
1714     if (ret) {
1715         HDF_LOGE("%s: error", __func__);
1716         return HDF_FAILURE;
1717     }
1718     HDF_LOGE("%s: success", __func__);
1719     return HDF_SUCCESS;
1720 }
1721 
CheckRawSdkIfSubmitRequest004(void)1722 int32_t CheckRawSdkIfSubmitRequest004(void)
1723 {
1724     int32_t ret;
1725 
1726     ret = UsbRawSubmitRequest(NULL);
1727     if (ret != HDF_ERR_INVALID_PARAM) {
1728         HDF_LOGE("%s: error", __func__);
1729         return HDF_FAILURE;
1730     }
1731     HDF_LOGE("%s: success", __func__);
1732     return HDF_SUCCESS;
1733 }
1734 
CheckRawSdkIfCancelRequest001(void)1735 int32_t CheckRawSdkIfCancelRequest001(void)
1736 {
1737     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1738 
1739     for (int32_t i = 0; i < ACM_NW; i++) {
1740         struct RawWb *snd = &rawAcm->wb[i];
1741         int32_t ret = UsbRawCancelRequest(snd->request);
1742         if (ret != HDF_SUCCESS) {
1743             HDF_LOGE("%s: error", __func__);
1744             return HDF_FAILURE;
1745         }
1746     }
1747     return HDF_SUCCESS;
1748 }
1749 
CheckRawSdkIfCancelRequest002(void)1750 int32_t CheckRawSdkIfCancelRequest002(void)
1751 {
1752     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1753 
1754     for (int32_t i = 0; i < ACM_NR; i++) {
1755         int32_t ret = UsbRawCancelRequest(rawAcm->readReq[i]);
1756         printf("%s+%d+ret:%d\n", __func__, __LINE__, ret);
1757         if (ret != HDF_SUCCESS) {
1758             HDF_LOGE("%s: error", __func__);
1759             return HDF_FAILURE;
1760         }
1761     }
1762     HDF_LOGE("%s: success", __func__);
1763     return HDF_SUCCESS;
1764 }
1765 
CheckRawSdkIfCancelRequest003(void)1766 int32_t CheckRawSdkIfCancelRequest003(void)
1767 {
1768     int32_t ret;
1769     struct AcmRawDevice *rawAcm = UsbGetIoAcm();
1770 
1771     ret = UsbRawCancelRequest(rawAcm->notifyReq);
1772     if (ret) {
1773         HDF_LOGE("%s: error", __func__);
1774         return HDF_FAILURE;
1775     }
1776     HDF_LOGE("%s: success", __func__);
1777     return HDF_SUCCESS;
1778 }
1779 
CheckRawSdkIfCancelRequest004(void)1780 int32_t CheckRawSdkIfCancelRequest004(void)
1781 {
1782     int32_t ret;
1783 
1784     ret = UsbRawCancelRequest(NULL);
1785     if (ret != HDF_ERR_INVALID_PARAM) {
1786         HDF_LOGE("%s: error", __func__);
1787         return HDF_FAILURE;
1788     }
1789     HDF_LOGE("%s: success", __func__);
1790     return HDF_SUCCESS;
1791 }
1792