equal
deleted
inserted
replaced
58 static RTest test(_L("T_USBAPI")); |
58 static RTest test(_L("T_USBAPI")); |
59 static RDevUsbcClient gPort; |
59 static RDevUsbcClient gPort; |
60 static RUsbOtgDriver gOTG; |
60 static RUsbOtgDriver gOTG; |
61 static TBool gSupportsOtg; |
61 static TBool gSupportsOtg; |
62 static TBool gSupportsHighSpeed; |
62 static TBool gSupportsHighSpeed; |
|
63 static TBool gSupportResouceAllocationV2; |
63 static TBool gUsingHighSpeed; |
64 static TBool gUsingHighSpeed; |
64 static TBool gSoak; |
65 static TBool gSoak; |
65 static TChar gKeychar = 'a'; |
66 static TChar gKeychar = 'a'; |
66 |
67 |
67 // Store the actual endpoint number(s) of our alternate interface |
68 // Store the actual endpoint number(s) of our alternate interface |
280 |
281 |
281 test.End(); |
282 test.End(); |
282 } |
283 } |
283 |
284 |
284 |
285 |
285 static void TestResourceAllocation() |
286 static void TestResourceAllocationV1() |
286 { |
287 { |
287 test.Start(_L("Test Endpoint Resource Allocation")); |
288 test.Start(_L("Test Endpoint Resource Allocation")); |
288 |
289 |
289 test.Next(_L("Request DMA resource")); |
290 test.Next(_L("Request DMA resource")); |
290 const TInt dma = gPort.AllocateEndpointResource(EEndpoint1, EUsbcEndpointResourceDMA); |
291 const TInt dma = gPort.AllocateEndpointResource(EEndpoint1, EUsbcEndpointResourceDMA); |
345 test(r == KErrNone); |
346 test(r == KErrNone); |
346 TInt n = d_caps().iTotalEndpoints; |
347 TInt n = d_caps().iTotalEndpoints; |
347 |
348 |
348 // Global variable - we'll need this value later |
349 // Global variable - we'll need this value later |
349 gSupportsHighSpeed = d_caps().iHighSpeed; |
350 gSupportsHighSpeed = d_caps().iHighSpeed; |
350 |
351 gSupportResouceAllocationV2 = (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2); |
|
352 |
351 test.Printf(_L("### USB device capabilities:\n")); |
353 test.Printf(_L("### USB device capabilities:\n")); |
352 test.Printf(_L("Number of endpoints: %d\n"), n); |
354 test.Printf(_L("Number of endpoints: %d\n"), n); |
353 test.Printf(_L("Supports Software-Connect: %s\n"), |
355 test.Printf(_L("Supports Software-Connect: %s\n"), |
354 d_caps().iConnect ? _S("yes") : _S("no")); |
356 d_caps().iConnect ? _S("yes") : _S("no")); |
355 test.Printf(_L("Device is Self-Powered: %s\n"), |
357 test.Printf(_L("Device is Self-Powered: %s\n"), |
362 gSupportsOtg ? _S("yes") : _S("no")); |
364 gSupportsOtg ? _S("yes") : _S("no")); |
363 test.Printf(_L("Supports unpowered cable detection: %s\n"), |
365 test.Printf(_L("Supports unpowered cable detection: %s\n"), |
364 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
366 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
365 _S("yes") : _S("no")); |
367 _S("yes") : _S("no")); |
366 test.Printf(_L("Supports endpoint resource alloc scheme V2: %s\n"), |
368 test.Printf(_L("Supports endpoint resource alloc scheme V2: %s\n"), |
367 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ? |
369 gSupportResouceAllocationV2 ? _S("yes") : _S("no")); |
368 _S("yes") : _S("no")); |
|
369 |
370 |
370 test(n >= 2); |
371 test(n >= 2); |
371 test.Printf(_L("(Device has sufficient endpoints.)\n")); |
372 test.Printf(_L("(Device has sufficient endpoints.)\n")); |
372 |
373 |
373 // Endpoint caps |
374 // Endpoint caps |
444 r = gPort.GetAlternateSetting(ifc_no); |
445 r = gPort.GetAlternateSetting(ifc_no); |
445 test(r == KErrUsbDeviceNotConfigured); |
446 test(r == KErrUsbDeviceNotConfigured); |
446 |
447 |
447 // Some UDCs won't allow endpoint resource manipulation once the hardware has been |
448 // Some UDCs won't allow endpoint resource manipulation once the hardware has been |
448 // configured and turned on. So we do it here & now: |
449 // configured and turned on. So we do it here & now: |
449 TestResourceAllocation(); |
450 if (!gSupportResouceAllocationV2) |
|
451 { |
|
452 TestResourceAllocationV1(); |
|
453 } |
450 |
454 |
451 // On the other hand, since some UDCs won't let us test many features which require |
455 // On the other hand, since some UDCs won't let us test many features which require |
452 // register access until the USB hardware is powered up (and because it might start |
456 // register access until the USB hardware is powered up (and because it might start |
453 // out unpowered), we should turn it on here explicitly. |
457 // out unpowered), we should turn it on here explicitly. |
454 // (It will be turned off automatically by the PIL after all tests have been run, |
458 // (It will be turned off automatically by the PIL after all tests have been run, |
502 |
506 |
503 test.Next(_L("Releasing interface")); |
507 test.Next(_L("Releasing interface")); |
504 r = gPort.ReleaseInterface(0); |
508 r = gPort.ReleaseInterface(0); |
505 test(r == KErrNone); |
509 test(r == KErrNone); |
506 |
510 |
|
511 if (gSupportResouceAllocationV2) |
|
512 { |
|
513 test.Next(_L("setting resource allocation info on endpoint 1 with resource allocation scheme v2")); |
|
514 ifc().iEndpointData[0].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA; |
|
515 ifc().iEndpointData[0].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DoubleBuffering; |
|
516 } |
|
517 |
507 test.Next(_L("Setting interface")); |
518 test.Next(_L("Setting interface")); |
508 r = gPort.SetInterface(0, ifc); |
519 r = gPort.SetInterface(0, ifc); |
509 test(r == KErrNone); |
520 test(r == KErrNone); |
510 |
521 |
511 // Suspend thread before connecting again. |
522 // Suspend thread before connecting again. |
534 r = gPort.DeviceConnectToHost(); |
545 r = gPort.DeviceConnectToHost(); |
535 test(r == KErrNone); |
546 test(r == KErrNone); |
536 // Suspend thread to let things get stable on the bus. |
547 // Suspend thread to let things get stable on the bus. |
537 User::After(2000000); |
548 User::After(2000000); |
538 |
549 |
|
550 if (gSupportResouceAllocationV2) |
|
551 { |
|
552 test.Next(_L("endpoint 1 resource allocation results(resource allocation V2)")); |
|
553 TBool res = gPort.QueryEndpointResourceUse(EEndpoint1, EUsbcEndpointResourceDoubleBuffering); |
|
554 test.Printf(_L("Double Buffering on endpoint 1 %s\n"), |
|
555 res ? _S("now allocated") : _S("not allocated")); |
|
556 |
|
557 res = gPort.QueryEndpointResourceUse(EEndpoint1, EUsbcEndpointResourceDMA); |
|
558 test.Printf(_L("DMA on endpoint 1 %s\n"), |
|
559 res ? _S("still allocated") : _S("not allocated")); |
|
560 } |
|
561 |
539 test.End(); |
562 test.End(); |
540 } |
563 } |
541 |
564 |
542 |
565 |
543 static void TestDeviceDescriptor() |
566 static void TestDeviceDescriptor() |